Skip to content

Commit f5ee71d

Browse files
authored
Merge pull request #49 from TigerGraph-DevLabs/feature/tigergraph_api
feat: add get_edges method to Graph class
2 parents c440b4c + 10eb2ff commit f5ee71d

File tree

9 files changed

+831
-21
lines changed

9 files changed

+831
-21
lines changed

docs/reference/01_core/graph.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,79 @@ True
11231123
True
11241124
```
11251125

1126+
::: tigergraphx.core.Graph.get_edges
1127+
1128+
**Examples:**
1129+
1130+
```python
1131+
>>> G = Graph(graph_schema)
1132+
>>> persons = [
1133+
... ("Alice", {"age": 30, "gender": "Female"}),
1134+
... ("Bob", {"age": 28, "gender": "Male"}),
1135+
... ("Carol", {"age": 32, "gender": "Female"}),
1136+
... ]
1137+
>>> G.add_nodes_from(persons, "Person")
1138+
3
1139+
>>> friendships = [
1140+
... ("Alice", "Bob", {"closeness": 0.8}),
1141+
... ("Bob", "Carol", {"closeness": 0.6}),
1142+
... ("Alice", "Carol", {"closeness": 0.9}),
1143+
... ]
1144+
>>> G.add_edges_from(friendships, "Person", "Friendship", "Person")
1145+
3
1146+
>>> df = G.get_edges(edge_types="Friendship")
1147+
>>> print(df)
1148+
s t
1149+
0 Bob Carol
1150+
1 Bob Alice
1151+
2 Carol Bob
1152+
3 Carol Alice
1153+
4 Alice Bob
1154+
5 Alice Carol
1155+
>>> df = G.get_edges(
1156+
... edge_types="Friendship",
1157+
... filter_expression="e.closeness > 0.7",
1158+
... )
1159+
>>> print(df)
1160+
s t
1161+
0 Bob Alice
1162+
1 Carol Alice
1163+
2 Alice Bob
1164+
3 Alice Carol
1165+
>>> df = G.get_edges(
1166+
... edge_types="Friendship",
1167+
... return_attributes=["closeness"],
1168+
... )
1169+
>>> print(df)
1170+
s t closeness
1171+
0 Bob Carol 0.6
1172+
1 Bob Alice 0.8
1173+
2 Carol Bob 0.6
1174+
3 Carol Alice 0.9
1175+
4 Alice Bob 0.8
1176+
5 Alice Carol 0.9
1177+
>>> df = G.get_edges(
1178+
... edge_types="Friendship",
1179+
... limit=2,
1180+
... )
1181+
>>> print(df)
1182+
s t
1183+
0 Bob Carol
1184+
1 Bob Alice
1185+
>>> df = G.get_edges(
1186+
... edge_types="Friendship",
1187+
... source_node_alias="s",
1188+
... edge_alias="e",
1189+
... target_node_alias="t",
1190+
... filter_expression='s.gender == "Female" and t.age > 30',
1191+
... )
1192+
>>> print(df)
1193+
s t
1194+
0 Alice Carol
1195+
>>> G.clear()
1196+
True
1197+
```
1198+
11261199
::: tigergraphx.core.Graph.get_neighbors
11271200

11281201
**Examples:**

0 commit comments

Comments
 (0)