Created
May 12, 2021 06:02
-
-
Save TheNova22/0dd2f80dd31a8d3a4c69bcf58073d41e to your computer and use it in GitHub Desktop.
Graph Creation Using Matrix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vim: syntax=swift | |
func makeGraph(_ edges : [[Int]])->[Int:[Int]]{ | |
var dict : [Int:[Int]] = [:] | |
for node in edges{ | |
dict[node[0],default: []].append(node[1]) | |
} | |
return dict | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment