Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

networkx remove nodes with degree

import networkx

G1 = networkx.Graph()
G1.add_edges_from([('a','b'),('b','c'),('c','e'),('c','d'),('c','f'),('c','g')])
to_be_removed = [x for  x in G1.nodes() if G1.degree(x) <= 1]

for x in to_be_removed:
    G1.remove_node(x)

print(G1.edges())
Comment

PREVIOUS NEXT
Code Example
Python :: download python on wsl 
Python :: convert negative to zero in list in python 
Python :: python get cpu cores 
Python :: read csv as list python 
Python :: clear multiprocessing queue python 
Python :: how to make my jupyter prin full array 
Python :: os.system return value 
Python :: python count number of zeros in a column 
Python :: how to install drivers for selenium python 
Python :: linux ubuntu install python 3.7 
Python :: install multiprocessing python3 
Python :: pandas filter string contain 
Python :: python all possible combinations of multiple lists 
Python :: clearing all text from a file in python 
Python :: how to open any application using python 
Python :: python change working directory to file directory 
Python :: python replace space with underscore 
Python :: python error get line 
Python :: python hand tracking module 
Python :: cv2 draw box 
Python :: python delete all files in directory 
Python :: how to install python3 on ubuntu 
Python :: convert seconds to hours python 
Python :: extract float from string python 
Python :: read file line by line into list 
Python :: dataframe slice by list of values 
Python :: install python3.7 ubuntu 20.04 
Python :: how to send whatsapp message with python 
Python :: f string round 
Python :: show jpg in jupyter notebook 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =