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

Method add_nodes

easygraph/readwrite/gexf.py:307–344  ·  view source on GitHub ↗
(self, G, graph_element)

Source from the content-addressed store, hash-verified

305 self.xml.append(graph_element)
306
307 def add_nodes(self, G, graph_element):
308 nodes_element = Element("nodes")
309 for node, data in G.nodes.items():
310 node_data = data.copy()
311 node_id = str(node_data.pop("id", node))
312 kw = {"id": node_id}
313 label = str(node_data.pop("label", node))
314 kw["label"] = label
315 try:
316 pid = node_data.pop("pid")
317 kw["pid"] = str(pid)
318 except KeyError:
319 pass
320 try:
321 start = node_data.pop("start")
322 kw["start"] = str(start)
323 self.alter_graph_mode_timeformat(start)
324 except KeyError:
325 pass
326 try:
327 end = node_data.pop("end")
328 kw["end"] = str(end)
329 self.alter_graph_mode_timeformat(end)
330 except KeyError:
331 pass
332 # add node element with attributes
333 node_element = Element("node", **kw)
334 # add node element and attr subelements
335 default = G.graph.get("node_default", {})
336 node_data = self.add_parents(node_element, node_data)
337 if self.VERSION == "1.1":
338 node_data = self.add_slices(node_element, node_data)
339 else:
340 node_data = self.add_spells(node_element, node_data)
341 node_data = self.add_viz(node_element, node_data)
342 node_data = self.add_attributes("node", node_element, node_data, default)
343 nodes_element.append(node_element)
344 graph_element.append(nodes_element)
345
346 def get_attr_id(self, title, attr_type, edge_or_node, default, mode):
347 # find the id of the attribute or generate a new id

Callers 1

add_graphMethod · 0.95

Calls 9

add_parentsMethod · 0.95
add_slicesMethod · 0.95
add_spellsMethod · 0.95
add_vizMethod · 0.95
add_attributesMethod · 0.95
popMethod · 0.80
appendMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected