About s-walk, When I read the article, I have a question: for hyperedge-level s-walk, how to compute the path from a hyperedge to other hyperedge, the sequence included hypergraph's node, rather than only hyperedge?
922397935 opened this issue · comments
Libing Bai commented
Dear Author:
class SixByFive():
"""Example hypergraph with 6 nodes and 5 edges"""
def __init__(self):
mat = np.array([[1, 1, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0], [1, 1, 1, 1, 0, 0]]).transpose()
self.hypergraph = hnx.Hypergraph.from_numpy_array(mat)
H = SixByFive().hypergraph
def get_s_path(g, s, source):
lg = g.get_linegraph(s=s, edges=True)
print(list(lg.edges))
try:
path_dist = nx.single_source_shortest_path(lg, source)
except (nx.NetworkXNoPath, nx.NodeNotFound):
warnings.warn(f"No {s}-path between {source} and 1")
edge_dist = np.inf
return path_dist
path = get_s_path(H, s=3, source='e0')
print(path)
```python
![Snipaste_2023-11-11_03-41-45](https://github.com/pnnl/HyperNetX/assets/51594106/a76eeda7-9a50-4a38-aaff-8e934f13d62f)
![Snipaste_2023-11-11_03-33-53](https://github.com/pnnl/HyperNetX/assets/51594106/4493ddfd-1078-4708-acff-c54dabcc308c)
In 3-line graph, from e0 to e3, I want the path_dist: 'e3':['e0' 'v2', 'e3'}, 'e3': {'e0', 'v1', 'e3'}?
Brenda Praggastis commented
@q923397935 s-walks are not supported directly in HNX yet. s-distance is computed on s-linegraphs only, using NetworkX