(arrow_modern_graph)
| 488 | |
| 489 | |
| 490 | def test_project_subgraph(arrow_modern_graph): |
| 491 | graph = arrow_modern_graph |
| 492 | |
| 493 | sub_graph = graph.project(vertices={}, edges={}) |
| 494 | assert sub_graph.schema.vertex_labels == [] |
| 495 | assert sub_graph.schema.edge_labels == [] |
| 496 | with pytest.raises( |
| 497 | RuntimeError, |
| 498 | match="Failed to project to simple graph as no vertex exists in this graph", |
| 499 | ): |
| 500 | graphscope.pagerank(sub_graph) |
| 501 | |
| 502 | # project a sub_graph only contain person nodes |
| 503 | sub_graph = graph.project(vertices={"person": None}, edges={}) |
| 504 | assert sub_graph.schema.vertex_labels == ["person"] |
| 505 | assert sub_graph.schema.edge_labels == [] |
| 506 | with pytest.raises( |
| 507 | RuntimeError, |
| 508 | match="Failed to project to simple graph as no edge exists in this graph", |
| 509 | ): |
| 510 | graphscope.pagerank(sub_graph) |
| 511 | |
| 512 | graph = graph.project( |
| 513 | vertices={"person": None, "software": ["name", "id"]}, |
| 514 | edges={"created": ["eid", "weight"], "knows": None}, |
| 515 | ) |
| 516 | assert graph.schema.vertex_labels == ["person", "software"] |
| 517 | assert graph.schema.edge_labels == ["knows", "created"] |
| 518 | assert [p.id for p in graph.schema.get_vertex_properties("person")] == [0, 1, 2] |
| 519 | assert [p.id for p in graph.schema.get_vertex_properties("software")] == [0, 2] |
| 520 | assert [p.id for p in graph.schema.get_edge_properties("created")] == [0, 1] |
| 521 | assert [p.id for p in graph.schema.get_edge_properties("knows")] == [0, 1] |
| 522 | |
| 523 | graph = graph.project(edges={"knows": ["eid"]}, vertices={"person": None}) |
| 524 | |
| 525 | assert graph.schema.vertex_labels == ["person"] |
| 526 | assert graph.schema.edge_labels == ["knows"] |
| 527 | assert [p.id for p in graph.schema.get_vertex_properties("person")] == [0, 1, 2] |
| 528 | assert [p.id for p in graph.schema.get_edge_properties("knows")] == [0] |
| 529 | |
| 530 | with pytest.raises(ValueError, match="weight not exist in properties"): |
| 531 | graph = graph.project(edges={"knows": ["weight"]}, vertices={"person": []}) |
| 532 | |
| 533 | graph = graph.project(edges={"knows": []}, vertices={"person": []}) |
| 534 | assert not graph.schema.get_vertex_properties("person") |
| 535 | assert not graph.schema.get_edge_properties("knows") |
| 536 | |
| 537 | ret = graphscope.pagerank(graph) |
| 538 | graph = graph.add_column(ret, {"pr": "r"}) |
| 539 | assert len(graph.schema.get_vertex_properties("person")) == 1 |
| 540 | assert graph.schema.get_vertex_properties("person")[0].name == "pr" |
| 541 | |
| 542 | |
| 543 | def test_project_project(ldbc_graph): |
nothing calls this directly
no test coverage detected