March 2019
Intermediate to advanced
336 pages
9h 9m
English
The PrintLinks method of the SocialGraph class prints the links from vertex = 0 and all the links in the graph:
// Print Links Examplefunc (socialGraph *SocialGraph) PrintLinks() { var vertex int vertex = 0 fmt.Printf("Printing all links from %d\n", vertex) var link Link for _, link = range socialGraph.Links[vertex] { fmt.Printf("Link: %d -> %d (%d)\n", link.Vertex1, link.Vertex2, link.LinkWeight) } fmt.Println("Printing all links in graph.") var adjacent []Link for _, adjacent = range socialGraph.Links { for _, link = range adjacent { fmt.Printf("Link: %d -> %d (%d)\n", link.Vertex1, link.Vertex2, link.LinkWeight) } }}
Read now
Unlock full access