Project a subgraph from the property graph, and return a new graph. A graph produced by project just like a normal property graph, and can be projected further. Args: vertices (dict): key is the vertex label name, the value is a list of str, which represe
(
self,
vertices: Mapping[str, Union[List[str], None]],
edges: Mapping[str, Union[List[str], None]],
)
| 814 | return UnloadedGraph(self._session, self._unload_op) |
| 815 | |
| 816 | def project( |
| 817 | self, |
| 818 | vertices: Mapping[str, Union[List[str], None]], |
| 819 | edges: Mapping[str, Union[List[str], None]], |
| 820 | ): |
| 821 | """Project a subgraph from the property graph, and return a new graph. |
| 822 | A graph produced by project just like a normal property graph, and can be projected further. |
| 823 | |
| 824 | Args: |
| 825 | vertices (dict): |
| 826 | key is the vertex label name, the value is a list of str, which represents the |
| 827 | name of properties. Specifically, it will select all properties if value is None. |
| 828 | Note that, the label of the vertex in all edges you want to project should be included. |
| 829 | edges (dict): |
| 830 | key is the edge label name, the value is a list of str, which represents the |
| 831 | name of properties. Specifically, it will select all properties if value is None. |
| 832 | |
| 833 | Returns: |
| 834 | :class:`graphscope.framework.graph.GraphDAGNode`: |
| 835 | A new graph projected from the property graph, evaluated in eager mode. |
| 836 | """ |
| 837 | check_argument(self.graph_type == graph_def_pb2.ARROW_PROPERTY) |
| 838 | if isinstance(vertices, (list, set)) or isinstance(edges, (list, set)): |
| 839 | raise ValueError( |
| 840 | "\nThe project vertices or edges cannot be a set or a list, rather, a dict is expected, \n" |
| 841 | "where the key is the label name and the value is a list of property name. E.g.,\n" |
| 842 | "\n" |
| 843 | " g.project(vertices={'person': ['name', 'age']},\n" |
| 844 | " edges={'knows': ['weight']})\n" |
| 845 | "\n" |
| 846 | "The property list for vertices and edges can be empty if not needed, e.g.,\n" |
| 847 | "\n" |
| 848 | " g.project(vertices={'person': []}, edges={'knows': []})\n" |
| 849 | ) |
| 850 | |
| 851 | op = dag_utils.project_arrow_property_graph( |
| 852 | self, json.dumps(vertices), json.dumps(edges) |
| 853 | ) |
| 854 | # construct dag node |
| 855 | graph_dag_node = GraphDAGNode( |
| 856 | self._session, |
| 857 | op, |
| 858 | self._oid_type, |
| 859 | self._vid_type, |
| 860 | self._directed, |
| 861 | self._generate_eid, |
| 862 | self._retain_oid, |
| 863 | self._vertex_map, |
| 864 | self._compact_edges, |
| 865 | self._use_perfect_hash, |
| 866 | ) |
| 867 | graph_dag_node._base_graph = self |
| 868 | return graph_dag_node |
| 869 | |
| 870 | |
| 871 | class Graph(GraphInterface): |
nothing calls this directly
no test coverage detected