MCPcopy Create free account
hub / github.com/alibaba/GraphScope / add_edges

Method add_edges

python/graphscope/framework/graph.py:552–713  ·  view source on GitHub ↗

Add edges to the graph, and return a new graph. Here the src_label and dst_label must be both specified or both unspecified, i. src_label and dst_label both unspecified and current graph has no vertex label. We deduce vertex label from edge table, and set vertex label n

(
        self,
        edges,
        label="_e",
        properties=None,
        src_label=None,
        dst_label=None,
        src_field: Union[int, str] = 0,
        dst_field: Union[int, str] = 1,
    )

Source from the content-addressed store, hash-verified

550 return graph_dag_node
551
552 def add_edges(
553 self,
554 edges,
555 label="_e",
556 properties=None,
557 src_label=None,
558 dst_label=None,
559 src_field: Union[int, str] = 0,
560 dst_field: Union[int, str] = 1,
561 ):
562 """Add edges to the graph, and return a new graph.
563 Here the src_label and dst_label must be both specified or both unspecified,
564
565 i. src_label and dst_label both unspecified and current graph has no vertex label.
566
567 We deduce vertex label from edge table, and set vertex label name to '_'.
568
569 ii. src_label and dst_label both unspecified and current graph has one vertex label.
570
571 We set src_label and dst label to this single vertex label.
572
573 ii. src_label and dst_label both specified and existed in current graph's vertex labels.
574
575 iii. src_label and dst_label both specified and some are not existed in current graph's vertex labels.
576
577 We deduce missing vertex labels from edge tables.
578
579
580 Args:
581 edges (Union[str, Loader]): Edge data source.
582 label (str, optional): Edge label name. Defaults to "_e".
583 properties (list[str], optional): List of column names loaded as properties. Defaults to None.
584 src_label (str, optional): Source vertex label. Defaults to None.
585 dst_label (str, optional): Destination vertex label. Defaults to None.
586 src_field (int, optional): Column index or name used as src field. Defaults to 0.
587 dst_field (int, optional): Column index or name used as dst field. Defaults to 1.
588
589 Raises:
590 ValueError: If the given value is invalid or conflict with current graph.
591
592 Returns:
593 :class:`graphscope.framework.graph.GraphDAGNode`:
594 A new graph with edge added, evaluated in eager mode.
595 """
596 if self._compact_edges:
597 raise ValueError(
598 "Cannot incrementally add edges to graphs with compacted edges, "
599 "please use `graphscope.load_from()` instead."
600 )
601 if src_label is None and dst_label is None:
602 check_argument(
603 len(self._v_labels) <= 1,
604 "Ambiguous vertex label, please specify the src_label and dst_label.",
605 )
606 if len(self._v_labels) == 1:
607 src_label = dst_label = self._v_labels[0]
608 else:
609 src_label = dst_label = "_"

Callers

nothing calls this directly

Calls 8

add_sub_labelMethod · 0.95
check_argumentFunction · 0.90
EdgeSubLabelClass · 0.90
EdgeLabelClass · 0.90
GraphDAGNodeClass · 0.85
add_opMethod · 0.80
appendMethod · 0.65

Tested by

no test coverage detected