MCPcopy Create free account
hub / github.com/iovisor/bcc / node_link_data

Method node_link_data

tools/deadlock.py:110–136  ·  view source on GitHub ↗

Returns the graph as a dictionary in a format that can be serialized.

(self)

Source from the content-addressed store, hash-verified

108 return graph
109
110 def node_link_data(self):
111 '''
112 Returns the graph as a dictionary in a format that can be
113 serialized.
114 '''
115 data = {
116 'directed': True,
117 'multigraph': False,
118 'graph': {},
119 'links': [],
120 'nodes': [],
121 }
122
123 # Do one pass to build a map of node -> position in nodes
124 node_to_number = {}
125 for node in self.adjacency_map.keys():
126 node_to_number[node] = len(data['nodes'])
127 data['nodes'].append({'id': node})
128
129 # Do another pass to build the link information
130 for node, neighbors in self.adjacency_map.items():
131 for neighbor in neighbors:
132 link = self.attributes_map[(node, neighbor)].copy()
133 link['source'] = node_to_number[node]
134 link['target'] = node_to_number[neighbor]
135 data['links'].append(link)
136 return data
137
138
139def strongly_connected_components(G):

Callers 1

mainFunction · 0.95

Calls 2

keysMethod · 0.80
itemsMethod · 0.80

Tested by

no test coverage detected