I'm getting really frustrated using the pygraph library for building hypergraphs with Python.
I'm trying to link two different nodes (75, 69) to a hyperedge (31), and then link that hyperedge to other two different nodes (71, 70).
i.e: (75,69) ---> (31) ---> (71,70)
So:
h = hypergraph()
h.add_nodes(['75','69','71','70'])
h.add_hyperedges(['31'])
h.link('71', '31')
h.link('70', '31')
That linked the hyperedge to nodes 70 and 71. But I don't know how to link the first two nodes to the hyperedge since link()
only accepts node
and hyperedge
as parameters in this order, and that only lets me link the hyperedge to a node and not vice versa (node to hyperedge).
The relationship between nodes and edges is always undirected. If you need properties on the connection between node and edge, you're effectively elevating those connections to edges themselves, so you have one group of nodes (the original nodes), another group of nodes (the former hyperedges) and finally the edges between nodes of the two types, which can then be directed.
If you say, no, you need a particular property of this being a hypergraph, it would be interesting to learn what that is!