I have Directed Graph in networkx. I want to only keep those nodes which have two or more than two outgoing edges or no outgoing edge at all. How do I do this?
or
How do I removes nodes which have exactly one outgoing edge in a networkx graph.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can find the nodes in graph
Gwith one outgoing edge using theout_degreemethod:Removing is then:
If you prefer to create a new graph instead of modifying the existing graph in place, create a subgraph: