MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / add_graph

Method add_graph

easygraph/readwrite/gexf.py:284–305  ·  view source on GitHub ↗
(self, G)

Source from the content-addressed store, hash-verified

282 return s
283
284 def add_graph(self, G):
285 # first pass through G collecting edge ids
286 for u, v, dd in G.edges:
287 eid = dd.get("id")
288 if eid is not None:
289 self.all_edge_ids.add(str(eid))
290 # set graph attributes
291 if G.graph.get("mode") == "dynamic":
292 mode = "dynamic"
293 else:
294 mode = "static"
295 # Add a graph element to the XML
296 if G.is_directed():
297 default = "directed"
298 else:
299 default = "undirected"
300 name = G.graph.get("name", "")
301 graph_element = Element("graph", defaultedgetype=default, mode=mode, name=name)
302 self.graph_element = graph_element
303 self.add_nodes(G, graph_element)
304 self.add_edges(G, graph_element)
305 self.xml.append(graph_element)
306
307 def add_nodes(self, G, graph_element):
308 nodes_element = Element("nodes")

Callers 3

write_gexfFunction · 0.95
generate_gexfFunction · 0.95
__init__Method · 0.95

Calls 5

add_nodesMethod · 0.95
add_edgesMethod · 0.95
addMethod · 0.80
appendMethod · 0.80
is_directedMethod · 0.45

Tested by

no test coverage detected