Skip to content

Commit

Permalink
add python tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rachchan committed Mar 10, 2023
1 parent fb773c7 commit 59e0fb8
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions raphtory/tests/test_graphdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from raphtory import algorithms
from raphtory import Perspective


def create_graph(num_shards):
g = Graph(num_shards)

Expand All @@ -20,7 +21,8 @@ def create_graph(num_shards):
g.add_vertex(6, 3, {"type": "wallet", "cost": 76})

for e in edges:
g.add_edge(e[0], e[1], e[2], {"prop1": 1, "prop2": 9.8, "prop3": "test"})
g.add_edge(e[0], e[1], e[2], {"prop1": 1,
"prop2": 9.8, "prop3": "test"})

return g

Expand Down Expand Up @@ -176,6 +178,7 @@ def test_windowed_graph_vertices():

assert vertices == [1, 2]


def test_windowed_graph_neighbours():
g = create_graph(1)

Expand Down Expand Up @@ -256,7 +259,8 @@ def test_windowed_graph_vertex_props():

view = g.window(min_size, max_size)

assert view.vertex(1).props() == {'cost': [(0, 99.5)], 'type': [(0, 'wallet')]}
assert view.vertex(1).props() == {
'cost': [(0, 99.5)], 'type': [(0, 'wallet')]}


def test_windowed_graph_edge_prop():
Expand All @@ -274,20 +278,32 @@ def test_windowed_graph_edge_prop():
assert edge.prop("undefined") == []


def test_local_triangle_count():
def test_algorithms():

g = Graph(1)

g.add_edge(1, 1, 2, {"prop1": 1})
g.add_edge(2, 2, 3, {"prop1": 1})
g.add_edge(3, 3, 1, {"prop1": 1})


view = g.window(0, 4)
triangles = algorithms.triangle_count(view, 1)
average_degree = algorithms.avg_degree(view)
max_out_degree = algorithms.max_outdegree(view)
max_in_degree = algorithms.max_indegree(view)
min_out_degree = algorithms.min_outdegree(view)
min_in_degree = algorithms.min_indegree(view)
graph_density = algorithms.graph_density(view)
clustering_coefficient = algorithms.clustering_coefficient(view, 1)

assert triangles == 1

assert average_degree == 2.0
assert graph_density == 0.5
assert max_out_degree == 1
assert max_in_degree == 1
assert min_out_degree == 1
assert min_in_degree == 1
assert clustering_coefficient == 1.0

def test_perspective_set():
g = create_graph(1)
Expand Down

0 comments on commit 59e0fb8

Please sign in to comment.