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

Method consolidate_columns

python/graphscope/framework/graph.py:715–761  ·  view source on GitHub ↗

Consolidate columns of given vertex / edge properties (of same type) into one column. For example, if we have a graph with vertex label "person", and edge labels "knows" and "follows", and we want to consolidate the "weight0", "weight1" properties of the vertex and both edge

(
        self,
        label: str,
        columns: Union[List[str], Tuple[str]],
        result_column: str,
    )

Source from the content-addressed store, hash-verified

713 return graph_dag_node
714
715 def consolidate_columns(
716 self,
717 label: str,
718 columns: Union[List[str], Tuple[str]],
719 result_column: str,
720 ):
721 """Consolidate columns of given vertex / edge properties (of same type) into one column.
722
723 For example, if we have a graph with vertex label "person", and edge labels "knows"
724 and "follows", and we want to consolidate the "weight0", "weight1" properties of the
725 vertex and both edges into a new column "weight", we can do:
726
727 .. code:: python
728
729 >>> g = ...
730 >>> g = g.consolidate_columns("person", ["weight0", "weight1"], "weight")
731 >>> g = g.consolidate_columns("knows", ["weight0", "weight1"], "weight")
732 >>> g = g.consolidate_columns("follows", ["weight0", "weight1"], "weight")
733
734 Args:
735 label: the label of the vertex or edge.
736 columns (dict): the properties of given vertex or edge to be consolidated.
737 result_column: the name of the new column.
738
739 Returns:
740 :class:`graphscope.framework.graph.GraphDAGNode`:
741 A new graph with column consolidated, evaluated in eager mode.
742 """
743 check_argument(
744 isinstance(columns, (list, tuple)),
745 "columns must be a list or tuple of strings",
746 )
747 op = dag_utils.consolidate_columns(self, label, columns, result_column)
748 graph_dag_node = GraphDAGNode(
749 self._session,
750 op,
751 self._oid_type,
752 self._vid_type,
753 self._directed,
754 self._generate_eid,
755 self._retain_oid,
756 self._vertex_map,
757 self._compact_edges,
758 self._use_perfect_hash,
759 )
760 graph_dag_node._base_graph = self
761 return graph_dag_node
762
763 def _backtrack_graph_dag_node_by_op_key(self, key):
764 if self.op.key == key:

Callers

nothing calls this directly

Calls 3

check_argumentFunction · 0.90
GraphDAGNodeClass · 0.85
consolidate_columnsMethod · 0.45

Tested by

no test coverage detected