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

Method add_edges

easygraph/readwrite/graphml.py:589–619  ·  view source on GitHub ↗
(self, G, graph_element)

Source from the content-addressed store, hash-verified

587 graph_element.append(node_element)
588
589 def add_edges(self, G, graph_element):
590 if G.is_multigraph():
591 for u, v, key, data in G.edges:
592 edge_element = self.myElement(
593 "edge",
594 source=str(u),
595 target=str(v),
596 id=str(data.get(self.edge_id_from_attribute))
597 if self.edge_id_from_attribute
598 and self.edge_id_from_attribute in data
599 else str(key),
600 )
601 default = G.graph.get("edge_default", {})
602 self.add_attributes("edge", edge_element, data, default)
603 graph_element.append(edge_element)
604 else:
605 for u, v, data in G.edges:
606 if self.edge_id_from_attribute and self.edge_id_from_attribute in data:
607 # select attribute to be edge id
608 edge_element = self.myElement(
609 "edge",
610 source=str(u),
611 target=str(v),
612 id=str(data.get(self.edge_id_from_attribute)),
613 )
614 else:
615 # default: no edge id
616 edge_element = self.myElement("edge", source=str(u), target=str(v))
617 default = G.graph.get("edge_default", {})
618 self.add_attributes("edge", edge_element, data, default)
619 graph_element.append(edge_element)
620
621 def add_graph_element(self, G):
622 """

Callers 2

add_graph_elementMethod · 0.95
add_graph_elementMethod · 0.45

Calls 3

add_attributesMethod · 0.95
appendMethod · 0.80
is_multigraphMethod · 0.45

Tested by

no test coverage detected