networkx

Is there a NetworkX function to find the k-nearest nodes of 0-degree nodes

Is there a NetworkX function to find the k-nearest nodes of 0-degree nodes Question: I am trying to connect the centroids of buildings (and other areas) to a NetworkX.MultiGraph representing the road network. These centroids are all 0-degree nodes. I have read posts on finding the nearest neighbors in the same graph but failed to …

Total answers: 1

Finding the root nodes in a networkx.Graph() and paths between those nodes

Finding the root nodes in a networkx.Graph() and paths between those nodes Question: This should be a simple question, but one I am not sure how to answer since I am new to the networkx api. The graphs I will be working with will not be directed and be acyclic. I have created a nx.Graph(), …

Total answers: 1

Transform a dataframe for network analysis using pandas

Transform a dataframe for network analysis using pandas Question: I have a data frame of online game matches including two specific columns: IDs of matches and IDs of players participated in a particular match. For instance: match_id player_id 0 1 0 2 0 3 0 4 0 5 1 6 1 1 1 7 1 …

Total answers: 3

Drawing a directed graph from a list of nodes with Python

Drawing a directed graph from a list of nodes with Python Question: That’s the ending graph that I would like to end up with, but to begin with it would be great to have simply bus late and overslept without considering the alarm on node. I would like to know how to draw a directed …

Total answers: 2

Find connected components recursively in a data frame

Find connected components recursively in a data frame Question: Consider the following data frame: import numpy as np import pandas as pd df = pd.DataFrame( { "main": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "component": [ [1, 2], [np.nan], [3, 8], [np.nan], [1, 5, 6], [np.nan], [7], [np.nan], [9, 10], [np.nan], …

Total answers: 1

Remove all nodes that has a particular attribute in networkx

Remove all nodes that has a particular attribute in networkx Question: I`m trying to remove all nodes within a Graph that has an specific attribute value. I have seen this: python networkx remove nodes and edges with some condition But in that case the degree is a property and not an attribute. My graph has …

Total answers: 1

create apache age graph from networkx graph

create apache age graph from networkx graph Question: I’ve started using apache age and was wondering if there is a cool way to directly put networkx graph into the apache age database? I’m using a workaround to get the edged and nodes associated with their attributes to insert them in the apache age using for …

Total answers: 3

Colors problem in plotting figure with matplotlib in python

Colors problem in plotting figure with matplotlib in python Question: I am trying to plot a bipartite graph to highlight the differences between two rankings. I am doing so by connecting the city in the left list to the same city on the right list with a colored arrow. The color should be proportional to …

Total answers: 1

Plotly Dash change networkx node colours in based on user input?

Plotly Dash change networkx node colours in based on user input? Question: After creating the minimal working example below, I tried to change the color of the nodes in the graphs based on user input. Specifically, I have n lists of colors (one color per node), and I would like the user to be able …

Total answers: 2

AttributeError: module 'networkx' has no attribute 'from_numpy_matrix'

AttributeError: module 'networkx' has no attribute 'from_numpy_matrix' Question: A is co occurrence dataframe. Why it shown AttributeError: module ‘networkx’ has no attribute ‘from_numpy_matrix’ import numpy as np import networkx as nx import matplotlib A=np.matrix(coocc) G=nx.from_numpy_matrix(A) Asked By: Pranab || Source Answers: In networkx 3.0 the changelog shows the following "Remove to_numpy_matrix & from_numpy_matrix (#5746)" https://networkx.org/documentation/stable/release/release_3.0.html …

Total answers: 2