March 2019
Intermediate to advanced
336 pages
9h 9m
English
The AddLink method of the SocialGraph class takes name1 and name2 as parameters. This method creates the entities if the named entities do not exist and creates a link between the entities:
// Add Linkfunc (socialGraph *SocialGraph) AddLink(name1 Name, name2 Name) { var exists bool if _, exists = socialGraph.GraphNodes[name1]; !exists { socialGraph.AddEntity(name1) } if _, exists = socialGraph.GraphNodes[name2]; !exists { socialGraph.AddEntity(name2) } if _, exists = socialGraph.Links[name1]; !exists { socialGraph.Links[name1] = make(map[Name]struct{}) } socialGraph.Links[name1][name2] = struct{}{}}
Read now
Unlock full access