6,064 questions
0
votes
0
answers
53
views
how to compare statistical difference between graphs in NetworkX
I have a number of graphs in NetworkX, obtained by microscopic images by NEFI https://nefi.mpi-inf.mpg.de/.
Since they're from real images, the graphs nodes are always slightly displaced from one ...
Advice
0
votes
1
replies
34
views
Double Vertex Graph for Train Networks
I came across one of OpenTrack's manuals. I couldn't find a more up to date version, this is the latest screenshot I could find.
Is the description vertex-vertex-edge-vertex-vertex actually correct?
...
2
votes
1
answer
55
views
Can't get the x axis tick label to appear
I've been trying hours to show the x axis label in my GraphRAG plot. The below is similar to my actual code but when I run this, the x axis label just doesn't appear?
I am not sure if it's because the ...
0
votes
1
answer
97
views
Networkx - how to use full canvas space
When generating a diagram with networkx and pyplot, the diagram is squashed in the middle with lots of empty white space around it.
import networkx as nx
import matplotlib.pyplot as plt
print(f"...
3
votes
0
answers
121
views
Efficient creation of Hasse diagrams with networkx
In python, with networkx, I have a large list li = [o1, o2, ...] of objects of a class Myclass. The class has a partial ordering for objects defined through the method __lt__. This is a strict ...
2
votes
1
answer
89
views
How to assign subgraph IDs based on weakly connected user pairs, but split when no shared connection exists
I'm working with a dataset where I want to assign a sub_graph ID to user interactions. Each row in the data represents a directed edge between an actor_user_id and a related_user_id.
I want to compute ...
0
votes
1
answer
85
views
Is there a way to draw the graph "features" with networkx in Python?
Is there a way to draw the graph "features" with networkx ?
(-1, 0 and 1 in my example)
With my Python code, currently it does not draw it.
See code below:
import torch
from torch_geometric....
4
votes
3
answers
132
views
Efficient way creating a dict of dict from a pandas dataframe
I have a pandas dataframe of the following structure:
d = {'I': ['A', 'B', 'C', 'D'], 'X': [ 1, 0, 3, 1], 'Y': [0, 1, 2, 1], 'Z': [1, 0, 0, 0], 'W': [3, 2, 0, 0]}
df = pd.DataFrame(data=d, columns=['I'...
1
vote
1
answer
272
views
dowhy python library: module 'networkx.algorithms' has no attribute 'd_separated'
When I tried using the model.identify_effect() in the python dowhy library, I receive the above error. This occurs even if I use the examples provided in the Getting Started guide.
ChatGpt informs me ...
7
votes
1
answer
127
views
How to label multigraph edges with different weights in networkx?
I'm trying to write a script that prompts a user to input a transition probability matrix for a Markov chain, and then displays the associated transition diagram.
Here's the relevant code:
class ...
1
vote
1
answer
62
views
How can I create graph Projections in Neo4J for a very large graph
I have 7M nodes and 20M relationships, my goal is to run random walk and node2vec using gds.
My current strategy is -> create graph projection, run random walk , use my custom python code to create ...
1
vote
2
answers
84
views
Get order of nodes in DiGraph networkx
I have the next example of graph:
import networkx as nx
G=nx.DiGraph()
G.add_edges_from([('b','a'), ('b','c'), ('a','c'),('c','d')])
In visual way it should look like this:
digraph {
layout=&...
4
votes
1
answer
150
views
Restriction of traversal through specific aisles to "enter-exit from same side" in a pathfinding graph?
I'm working on a warehouse layout in Python where a route is calculated between multiple pick locations. The layout includes both wide and 'ultra-narrow' aisles. In the real-world setup, ultra-narrow ...
1
vote
1
answer
96
views
Build aggregated network graph from Pandas dataframe containing a column with list of nodes for each row?
I'm dipping my toes into network visualizations in Python. I have a dataframe like the following:
| user | nodes |
| -----| ---------|
| A | [0, 1, 3]|
| B | [1, 2, 4]|
| C | [0, 3] |
|.....
0
votes
0
answers
57
views
Direct and indirect connexion in a tree
Suppose a number of trees among which we have the following tree.
Tree configuration's is represented by 2 lists arranged as tuples representing tree edge's:
ss-pair=[(1, 2), (2, 3), (3, 4), (4, 5), (...
3
votes
0
answers
75
views
Finding a negative cycle in networkx
In networkx there is a function find_negative_cycle, for finding a negative cycle in a weighted graph. But, it requires to specify a node in the cycle:
find_negative_cycle(G, source)
If I am ...
0
votes
1
answer
61
views
Create a graph using the edge attribute as node
I have a directed graph where the edges have the attribute edge_id. I want to create a new graph using the edge_id as nodes.
I think there should be some more straightforward method than this?
import ...
2
votes
1
answer
202
views
Issues with Recursive Digraph Construction and Missing Loops in Python Code
I'm trying to write code to recursively generate directed graphs as described in the following process:
For G_1, we start with a single vertex with a self-loop.
For G_2, we take two copies of G_1, ...
0
votes
1
answer
69
views
How to efficiently apply batched edge/node modifications across multiple graph copies using precomputed data?
I'm working on a task where I need to apply custom modifications to many independent copies of the same base graph. For each instance, I want to:
Start from the same base graph
Remove one or more ...
1
vote
1
answer
137
views
Node/edge attributed directed graph embedding
What is the format of node features that graph2vec and GL2vec in karateclub require? It does mention that there should be no string features but with or without it I am running into an error with the ...
0
votes
1
answer
61
views
How to add spacing between nodes in networkx
I'm trying to make a graph to visualize parts in a product and their type of connection inbetween.
The labels between the nodes are important, not the labels on the nodes themselves. Sometimes the ...
0
votes
1
answer
56
views
python numpy and networkx returning different eigenvalues
I've been trying to calculate graph properties of any given graph using the networkx package and numpy in python. However, when I calculate the eigenvalues of a graph laplacian, it seems that numpy ...
0
votes
0
answers
24
views
Optimize Network Closure in Python with ±15 Adjustments
Problem Statement
I am working on a network closure problem where I have multiple nodes and their measured delays. Given a set of nodes and delay measurements, I need to ensure that each triangle of ...
0
votes
0
answers
57
views
How to convert .dimacs file to g6 with python
I would like to convert all my .dimacs graphs to .g6. I wrote a Python script to do this, but when I open my graph.g6, I realize that the string is not in the correct format. How can I properly ...
2
votes
2
answers
74
views
Adjacency matrix not square error from square dataframe with networkx
I have code that aims to generate a graph from an adjacency matrix from a table correlating workers with their manager. The source is a table with two columns (Worker, manager). It still works ...
0
votes
1
answer
70
views
Representing Networkx graphs as strings in a consistent way
I have multiple Networkx graphs (with node attributes), and I need to represent them as strings. There are several ways to do that, but I need to always get the same string for equal graphs (not ...
0
votes
0
answers
38
views
Inherited networkx subgraph method fails
A TypeError: MyNetwork.__init__() missing 1 required positional argument: 'some_parameter' is thrown on the last line of the following code snippet:
class MyNetwork(nx.DiGraph):
def __init__(self, ...
5
votes
2
answers
272
views
Generate all paths that consists of specified number of visits of nodes / edges
In a graph/chain there are 3 different states: ST, GRC_i and GRC_j.
The following edges between the states exists:
EDGES = [
# source, target, name
('ST', 'GRC_i', 'TDL_i'),
('ST', '...
0
votes
0
answers
35
views
Multi-layer modularity metric
I am stuck with computing the extended modularity metric on a multi-layer graph. I am trying to derive the result of the middle graph in Figure 6 of the following article: https://www.nature.com/...
2
votes
0
answers
93
views
How to prevent overlap visualizing tree diagram with networkx and graphviz?
Using networkx and graphviz, I am trying to visualize a tree with many nodes. No matter what parameters I use, I am unable to prevent the nodes from overlapping, which makes them illegible. Are there ...
1
vote
1
answer
98
views
How to convert 2D networkx graph to interactive 3D in python?
I have already built a network 2D graph using networkx in python.
Code used to build:
import pandas as pd
import matplotlib as mpl
links_data = pd.read_csv("https://raw.githubusercontent.com/...
2
votes
1
answer
39
views
How to color nodes in network graph based on categories in networkx python?
I am trying to create a network graph on correlation data and would like to color the nodes based on categories.
Data sample view:
Data:
import pandas as pd
links_data = pd.read_csv("https://...
2
votes
1
answer
255
views
Use Gurobi to create networkx.Graph that has highest edge connectivity
I have the following graph G
G is created using the following code
import networkx as nx
import matplotlib.pyplot as plt
G = nx.hoffman_singleton_graph()
pos = nx.spring_layout(G)
nx.draw(G, pos=pos)...
1
vote
1
answer
40
views
How to make both edges (1edge starting from a node and 2ndedge ending in that node) bw two nodes in a directed (asym) graph using networkx in python?
I have a distance matrix of 50 cities.
Sample matrix of the first 10 cities looks something like following:
0
1
2
3
4
5
6
7
8
9
0
0
Inf
1033.836
2954.445
Inf
570.7902
Inf
5201.642
927.6648
Inf
1
Inf
0
...
1
vote
1
answer
76
views
Get adjacency matrices of networkx.MultiDiGraph
I want to obtain the adjacency matrices of a networkx.MultiDiGraph. My code looks as follows:
import numpy as np
import networkx as nx
np.random.seed(123)
n_samples = 10
uv = [
(1, 2),
(2, 3),...
1
vote
2
answers
95
views
Using Python to group similar values from pair combinations
I have a list of paired values. Values in each pair are declared as similar, meaning two values are considered similar if they appear together in a pair from the list. My goal is to create a list of ...
1
vote
0
answers
61
views
Manual and software calculations of Brandes centrality are different
I have an undirected weighted graph:
I manually calculated the centrality for each node.
1 - 0
2 - 1.5
3 - 0
4 - 3
5 - 2
Then I calculated the centrality using this algorithm
import networkx as nx
G ...
1
vote
0
answers
38
views
Why does my generate_semieuler function fail the edge-case tests for semi-Eulerian directed graphs?
The task was: Write a function generate_semieuler that returns some directed semi-Eulerian graph on n vertices with m edges that has no bidirectional edges, or None if such a graph does not exist. ...
0
votes
0
answers
43
views
Adding Edge Color to the Network Graph using Networkx package
PATY_HI
PATY_LO
MATCH_KEY
WEIGHT_BUCKET
12345
6789
T
r
54321
3456
A;T
b
34567
12345
EP;T
y
I'm using the Networkx package to create a visualisation of the associations of a customer, so the user can ...
2
votes
2
answers
92
views
Predecessors from scipy depth_first_order
I use scipy version 1.14.1 to traverse the minimum spanning tree in depth-first order, but I do not understand some results, namely the predecessors returned by scipy are not correct.
Here is an ...
-1
votes
1
answer
48
views
Assignment to global variable attribute in for loop is not available outside the scope of the loop
This is a simplified version of this SO question (link) with some program output.
Using Python and networkX under macOS, I am not able to assign a value to an edge attribute as follows:
import ...
0
votes
1
answer
173
views
Outerplanar embedding algorithm
Does anyone know of an algorithm that can produce an outerplanar embedding of a graph? I am looking for something similar to check_planarity from NetworkX, which returns a planar embedding if the ...
0
votes
0
answers
23
views
Missing cliques in a Networkx graph
I have a connected graph that I have created using NetworkX. I am trying to find all cliques in this graph. I used enumerate_all_cliques() from the NetworkX package. This is only giving me cliques of ...
0
votes
1
answer
53
views
Scikit-learn estimator that accepts non array-like input
I am developing a scikit-learn estimator, the documentation states that the input "X" for the .fit() method should be an "array-like of shape (n_samples, n_features)".
However, my ...
1
vote
1
answer
46
views
How to create a connected 2D grid graph?
I have a 2-dimensional array that represents a grid. The (numpy) array is as follows:
dx_grid =[[ "A", "B", "C"],
[ "L", "M", "N"],...
0
votes
0
answers
57
views
Estimating average closeness centrality of a large graph in python in a reasonable time
I have a large network file (about 7 million nodes and 7 million edges) that i've imported in a networkx graph. I need to estimate its closeness centrality average across all nodes. I've tried ...
2
votes
1
answer
116
views
networkx finding shortest path in edge label order
I work for an airport, and my task is to calculate the taxiing routes for airplanes on taxiways, ensuring they follow the prescribed road sequence. Here, I'll give an example and would like to ask if ...
1
vote
1
answer
156
views
NetworkX find largest fully connected subset of points
I am new to graph theory and am trying to find the largest subset of x,y coordinate points in which all points in the subset are within a specified distance of one another. I am currently using the nx....
0
votes
1
answer
70
views
OSMnx throws exception when called on graph created from graph_from_gdfs
I'm trying to simplify a graph after modifying the gdf_edges and recreating the graph from the dataframes. My workflow is as follows:
ox.graph_from_polygon => graph_to_gdfs => modify gdf_edges =&...
0
votes
1
answer
67
views
Networkx python module function GraphMatcher.subgraph_is_isomorphic() usage
isomatcher = nx.isomorphism.GraphMatcher(G, H)
isomatcher.subgraph_is_isomorphic()
In my understanding this function returns True if a subgraph of G is isomorphic to H.
Yet when I run this code as ...