0

I am new to graph analysis using networkx. I created a directed acylic graph. My next step would be compute the levels for all nodes in the graph using antichain function. I checked the tutorial page and it states as:

antichains(G, topo_order=None)

I replaced topo_order=list and executed and object was created. How do I interpret the different levels and their corresponding nodes in it?. Kindly help me.

MSM
  • 85
  • 8
  • 1
    Does this answer your question? [Understanding generators in Python](https://stackoverflow.com/questions/1756096/understanding-generators-in-python) – warped Mar 10 '20 at 08:56
  • If you simply want to see, what the generator contains, you can use `print(list(anti chains(G,topo_order=list))` (you probably need to rename your list variable first, because you have overwritten the default method) – Sparky05 Mar 10 '20 at 09:09
  • @Sparky05. I tried this before. but I got the following error as "TypeError: 'type' object is not reversible". I also what to check how many levels are there and need to extract nodes at each levels – MSM Mar 10 '20 at 09:12
  • What does your `list` variable contains? – Sparky05 Mar 10 '20 at 09:37
  • @Sparky05 I am not sure with the antichain concept. My graph is a directed acylic graph. Does list contain the levels? – MSM Mar 10 '20 at 09:43
  • Try `antychain_list = list(nx.antichains(G))` and then print the results – Sparky05 Mar 10 '20 at 10:00
  • @Sparky05. Thank you for your patient. I tried several times and the window crashed. – MSM Mar 10 '20 at 10:15
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/209360/discussion-between-sparky05-and-msm). – Sparky05 Mar 10 '20 at 10:50

0 Answers0