networkx

Deleting nodes with tie=1 in a large NetworkX graph

狂风中的少年 提交于 2021-02-18 19:09:44
问题 I have made large graph with NetworkX with about 20,000 nodes. I would like to delete nodes with only one tie (or zero ties) to try to reduce the clutter. Since it is a very large graph I do not know the nodes by name or ID that have tie=1 or 0. Does anyone know how to delete these nodes without specifying the node ID or name? 回答1: Iterating on a Graph g yields all of g 's nodes, one at a time -- I believe you can't alter g during the iteration itself, but you can selectively make a list of

How do I curve edges in networkX graph

点点圈 提交于 2021-02-17 05:45:10
问题 I had previous asked this question on how to achieve curved edges in networkX. It was working fine with my previous data, but when I updated the data and the code I'm unsure where I'm going wrong. The edges are only curving for certain nodes, and actually adding connections twice. I don't know why it's drawing the edges twice, once in a straight line and once curved. My code: import matplotlib.pyplot as plt import networkx as nx G = nx.Graph() G.add_edge("Ted", "May", weight=0.5) G.add_edge(

How to use NetworkX's rescale_layout?

霸气de小男生 提交于 2021-02-11 13:11:57
问题 I am having a hard time understanding how to use NetworkX's rescale_layout. The documentation says: pos (numpy array) – positions to be scaled. Each row is a position which is not the standard "position dictionary" that the rest of NetworkX uses for plotting. I have tried to use NetworkX's to_numpy_array on the "pos dict" to no success, and the output of to_numpy_array is a Graph adjacency matrix which doesn't mesh with the requirement of rescale_layout 's Each position is one row of the

How to use NetworkX's rescale_layout?

和自甴很熟 提交于 2021-02-11 13:11:44
问题 I am having a hard time understanding how to use NetworkX's rescale_layout. The documentation says: pos (numpy array) – positions to be scaled. Each row is a position which is not the standard "position dictionary" that the rest of NetworkX uses for plotting. I have tried to use NetworkX's to_numpy_array on the "pos dict" to no success, and the output of to_numpy_array is a Graph adjacency matrix which doesn't mesh with the requirement of rescale_layout 's Each position is one row of the

How to increase label spacing to avoid label overlap in networkx graph

邮差的信 提交于 2021-02-11 13:10:34
问题 I want to plot a graph, where one node for each document exists and then other nodes for each word in it. This way I want to visualize words, that are occuring in multiple documents. Unfortunately the labels for the nodes overlap, so that they aren't very readable oftentimes. I have tried to increase and decrease the k variable, but it is not really helping. I noticed that the graph changes if its plotted again, and sometimes the labels are more readable, but its not very helpful because I

How to increase label spacing to avoid label overlap in networkx graph

旧街凉风 提交于 2021-02-11 13:04:52
问题 I want to plot a graph, where one node for each document exists and then other nodes for each word in it. This way I want to visualize words, that are occuring in multiple documents. Unfortunately the labels for the nodes overlap, so that they aren't very readable oftentimes. I have tried to increase and decrease the k variable, but it is not really helping. I noticed that the graph changes if its plotted again, and sometimes the labels are more readable, but its not very helpful because I

Append word to input file name for output file name

徘徊边缘 提交于 2021-02-11 05:15:57
问题 I am trying to read in some data, process the data, and write the results to a CSV saved with original file name + the word "folded". I'm using sys.argv to pass the input filename, and thought that I could just create a new variable such as filename = sys.argv[1]+'_folded.csv but I ended up with file.csv_folded.csv . How can I do this so my output file is saved as file_folded.csv? Simplified code example: import sys import networkx as nx G = nx.read_edgelist(sys.argv[1], delimitier=',')

Append word to input file name for output file name

白昼怎懂夜的黑 提交于 2021-02-11 05:12:39
问题 I am trying to read in some data, process the data, and write the results to a CSV saved with original file name + the word "folded". I'm using sys.argv to pass the input filename, and thought that I could just create a new variable such as filename = sys.argv[1]+'_folded.csv but I ended up with file.csv_folded.csv . How can I do this so my output file is saved as file_folded.csv? Simplified code example: import sys import networkx as nx G = nx.read_edgelist(sys.argv[1], delimitier=',')

Append word to input file name for output file name

冷暖自知 提交于 2021-02-11 05:12:14
问题 I am trying to read in some data, process the data, and write the results to a CSV saved with original file name + the word "folded". I'm using sys.argv to pass the input filename, and thought that I could just create a new variable such as filename = sys.argv[1]+'_folded.csv but I ended up with file.csv_folded.csv . How can I do this so my output file is saved as file_folded.csv? Simplified code example: import sys import networkx as nx G = nx.read_edgelist(sys.argv[1], delimitier=',')

Append word to input file name for output file name

混江龙づ霸主 提交于 2021-02-11 05:10:18
问题 I am trying to read in some data, process the data, and write the results to a CSV saved with original file name + the word "folded". I'm using sys.argv to pass the input filename, and thought that I could just create a new variable such as filename = sys.argv[1]+'_folded.csv but I ended up with file.csv_folded.csv . How can I do this so my output file is saved as file_folded.csv? Simplified code example: import sys import networkx as nx G = nx.read_edgelist(sys.argv[1], delimitier=',')