Skip to content

Instantly share code, notes, and snippets.

@TheNova22
Created May 12, 2021 06:02
Show Gist options
  • Save TheNova22/0dd2f80dd31a8d3a4c69bcf58073d41e to your computer and use it in GitHub Desktop.
Save TheNova22/0dd2f80dd31a8d3a4c69bcf58073d41e to your computer and use it in GitHub Desktop.
Graph Creation Using Matrix
// 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