-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added first version of functions * node tests * Adding persistent graph test * Added graphql tests * new 83 fmt * Added no-op for eventgraph/persistentgraph * Add individual in-component and out-component algorithms * Added in-component out-component functions * Tidy lucas comments * fmt * sort imports --------- Co-authored-by: Ben Steer <[email protected]> Co-authored-by: Ben Steer <[email protected]> Co-authored-by: Ben Steer <[email protected]>
- Loading branch information
1 parent
08ed007
commit 318dc9a
Showing
24 changed files
with
434 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from raphtory.graphql import RaphtoryClient | ||
from raphtory.graphql import GraphServer | ||
from raphtory import Graph | ||
import tempfile | ||
|
||
|
||
def test_in_out_components(): | ||
|
||
def sort_components(data): | ||
if "inComponent" in data: | ||
data["inComponent"] = sorted(data["inComponent"], key=lambda x: x["name"]) | ||
if "outComponent" in data: | ||
data["outComponent"] = sorted(data["outComponent"], key=lambda x: x["name"]) | ||
|
||
def prepare_for_comparison(structure): | ||
if "node" in structure: | ||
sort_components(structure["node"]) | ||
if "window" in structure: | ||
sort_components(structure["window"]["node"]) | ||
if "at" in structure: | ||
sort_components(structure["at"]["node"]) | ||
|
||
query = """ | ||
{ | ||
graph(path: "graph") { | ||
node(name: "3") { | ||
inComponent { | ||
name | ||
} | ||
outComponent { | ||
name | ||
} | ||
} | ||
window(start:1,end:6){ | ||
node(name:"3"){ | ||
inComponent{ | ||
name | ||
} | ||
} | ||
} | ||
at(time:4){ | ||
node(name:"4"){ | ||
outComponent{ | ||
name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
""" | ||
result = { | ||
"graph": { | ||
"node": { | ||
"inComponent": [{"name": "7"}, {"name": "1"}], | ||
"outComponent": [{"name": "6"}, {"name": "4"}, {"name": "5"}], | ||
}, | ||
"window": {"node": {"inComponent": [{"name": "1"}]}}, | ||
"at": {"node": {"outComponent": [{"name": "5"}]}}, | ||
} | ||
} | ||
work_dir = tempfile.mkdtemp() | ||
g = Graph() | ||
g.add_edge(1, 1, 2) | ||
g.add_edge(2, 1, 3) | ||
g.add_edge(3, 3, 4) | ||
g.add_edge(4, 4, 5) | ||
g.add_edge(5, 3, 6) | ||
g.add_edge(6, 7, 3) | ||
|
||
g.save_to_file(work_dir + "/graph") | ||
with GraphServer(work_dir).start(): | ||
client = RaphtoryClient("http://localhost:1736") | ||
query_res = client.query(query) | ||
prepare_for_comparison(query_res["graph"]) | ||
prepare_for_comparison(result["graph"]) | ||
assert query_res == result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.