Skip to content

Instantly share code, notes, and snippets.

@cornchz
Last active January 1, 2016 04:19
Show Gist options
  • Save cornchz/8090974 to your computer and use it in GitHub Desktop.
Save cornchz/8090974 to your computer and use it in GitHub Desktop.
Symmetrize edges

Run

# from files
./symmetrize.sh input

# from stdin
cat input | ./symmetrize.sh

Sample Input

1       1
1       2
3       4

Sample Output

1       1
1       2
2       1
3       4
4       3
awk '{ print $0 "\n" $2 "\t" $1 }' $@ | sort | awk 'p != $0 { print $0 } { p = $0 }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment