Add a node to the graph.
(self, G, node_xml, graphml_keys, defaults)
| 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.""" |
no test coverage detected