Issue
In NetworkX, I can use the nx.triadic_census(g)
to give me a list of triads in my network.
Out:
{'003': 1434217,
'012': 282025,
'102': 32640,
'021D': 21,
'021U': 267246,
'021C': 445}
I wanted to know how I can list the directed edges belonging to a triad. For example, in Pyspark, to list the nodes/edges in triad "102" : g.find("(a)-[e]->(b); (b)-[e2]->(a)").show()
and it will give you
| a| e| b| e2|
+--------------------+-------------+--------------------+--------------+
|[US, United State...| [US, AZ, 0]| [AZ, Azerbaijan]| [AZ, US, 637]|
| [LU, Luxembourg]|[LU, BE, 213]| [BE, Belgium]|[BE, LU, 1470]|
| [FI, Finland]| [FI, CZ, 24]|[CZ, Czech Republic]| [CZ, FI, 51]|
| [HU, Hungary]| [HU, PL, 0]| [PL, Poland]| [PL, HU, 231]|
|[RU, Russian Fede...| [RU, UA, 0]| [UA, Ukraine]| [UA, RU, 0]|
Is there a way for me to do this in NetworkX?
Solution
There is no function in networkx
that allow you to do it, so you should implement it manually. I modified the networkx.algorithms.triads
code to return triad nodes, not their count. You can find it here. It can be modified with replacing tuple in census['...'].add(tuple(sorted([u, v, w])))
lines to add edges instead of nodes.
Answered By - vurmux
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.