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

Method add_node

easygraph/readwrite/gexf.py:742–775  ·  view source on GitHub ↗
(self, G, node_xml, node_attr, node_pid=None)

Source from the content-addressed store, hash-verified

740 return G
741
742 def add_node(self, G, node_xml, node_attr, node_pid=None):
743 # add a single node with attributes to the graph
744
745 # get attributes and subattributues for node
746 data = self.decode_attr_elements(node_attr, node_xml)
747 data = self.add_parents(data, node_xml) # add any parents
748 if self.VERSION == "1.1":
749 data = self.add_slices(data, node_xml) # add slices
750 else:
751 data = self.add_spells(data, node_xml) # add spells
752 data = self.add_viz(data, node_xml) # add viz
753 data = self.add_start_end(data, node_xml) # add start/end
754
755 # find the node id and cast it to the appropriate type
756 node_id = node_xml.get("id")
757 if self.node_type is not None:
758 node_id = self.node_type(node_id)
759
760 # every node should have a label
761 node_label = node_xml.get("label")
762 data["label"] = node_label
763
764 # parent node id
765 node_pid = node_xml.get("pid", node_pid)
766 if node_pid is not None:
767 data["pid"] = node_pid
768
769 # check for subnodes, recursive
770 subnodes = node_xml.find(f"{{{self.NS_GEXF}}}nodes")
771 if subnodes is not None:
772 for node_xml in subnodes.findall(f"{{{self.NS_GEXF}}}node"):
773 self.add_node(G, node_xml, node_attr, node_pid=node_id)
774
775 G.add_node(node_id, **data)
776
777 def add_start_end(self, data, xml):
778 # start and end times

Callers 12

make_graphMethod · 0.95
from_agraphFunction · 0.45
to_agraphFunction · 0.45
parse_gml_linesFunction · 0.45
setup_classMethod · 0.45
setup_classMethod · 0.45
setup_classMethod · 0.45
build_graphMethod · 0.45

Calls 6

decode_attr_elementsMethod · 0.95
add_parentsMethod · 0.95
add_slicesMethod · 0.95
add_spellsMethod · 0.95
add_vizMethod · 0.95
add_start_endMethod · 0.95

Tested by 8

setup_classMethod · 0.36
setup_classMethod · 0.36
setup_classMethod · 0.36
build_graphMethod · 0.36