MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / test_from_graph_kHop

Function test_from_graph_kHop

easygraph/classes/tests/test_hypergraph.py:72–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70
71
72def test_from_graph_kHop():
73 g = eg.Graph()
74 g.add_nodes(range(0, 5))
75 g.add_edges(
76 [(0, 1), (0, 3), (1, 4), (2, 3)],
77 [{"weight": 1.0}, {"weight": 1.0}, {"weight": 1.0}, {"weight": 1.0}],
78 )
79 hg = eg.Hypergraph.from_graph_kHop(g, k=1)
80 assert hg.num_e == 5
81 assert (0, 1, 3) in hg.e[0]
82 assert (0, 1, 4) in hg.e[0]
83 assert (1, 4) in hg.e[0]
84 assert (2, 3) in hg.e[0]
85 assert (0, 2, 3) in hg.e[0]
86 hg = eg.Hypergraph.from_graph_kHop(g, k=2)
87 assert hg.num_e == 5
88 assert (0, 1, 3, 4) in hg.e[0]
89 hg = eg.Hypergraph.from_graph_kHop(g, k=2, only_kHop=True)
90 assert hg.num_e == 4
91 assert (1, 3) in hg.e[0]
92
93
94# def test_from_bigraph():

Callers

nothing calls this directly

Calls 4

add_nodesMethod · 0.95
add_edgesMethod · 0.95
GraphMethod · 0.80
from_graph_kHopMethod · 0.80

Tested by

no test coverage detected