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

Method add_node

easygraph/readwrite/graphml.py:908–922  ·  view source on GitHub ↗

Add a node to the graph.

(self, G, node_xml, graphml_keys, defaults)

Source from the content-addressed store, hash-verified

906 return G
907
908 def add_node(self, G, node_xml, graphml_keys, defaults):
909 """Add a node to the graph."""
910 # warn on finding unsupported ports tag
911 ports = node_xml.find(f"{{{self.NS_GRAPHML}}}port")
912 if ports is not None:
913 warnings.warn("GraphML port tag not supported.")
914 # find the node by id and cast it to the appropriate type
915 node_id = self.node_type(node_xml.get("id"))
916 # get data/attributes for node
917 data = self.decode_data_elements(graphml_keys, node_xml)
918 G.add_node(node_id, **data)
919 # get child nodes
920 if node_xml.attrib.get("yfiles.foldertype") == "group":
921 graph_xml = node_xml.find(f"{{{self.NS_GRAPHML}}}graph")
922 self.make_graph(graph_xml, graphml_keys, defaults, G)
923
924 def add_edge(self, G, edge_element, graphml_keys):
925 """Add an edge to the graph."""

Callers 1

make_graphMethod · 0.95

Calls 2

decode_data_elementsMethod · 0.95
make_graphMethod · 0.95

Tested by

no test coverage detected