Questions tagged [weighted-graph]
144 questions
1
vote
1 answer
How to efficiently get edge weights from a networkx graph? (nx.Graph)
I'm trying to get the edge weights from a nx.Graph but the only way I could figure out iterates through the entire network. Is there a more efficient way to do this from networkx my nx.Graph assuming that I did not previously have the pd.DataFrame?…

O.rka
- 29,847
- 68
- 194
- 309
1
vote
1 answer
Keeping track of the shortest path between two nodes using Dijkstra's algorithm
I am quite new to c++ and have been having trouble modifying Dijkstra's algorithm to keep track of the shortest path between two nodes, not just the shortest distance. I have it computing the shortest distance correctly. This is the function that…

Dov Royal
- 49
- 2
- 9
1
vote
1 answer
Why does my Dijkstra algorithm work for negative weights? Did I implement it incorrectly and am I sacrificing runtime?
public static void Dijkstra(Hashtable ht,String start)
{
ht.get(start).setWeight(0);
Set keys = ht.keySet();
PriorityQueue pq = new PriorityQueue<>();
for(String key: keys)
…

V. M.
- 65
- 1
- 5
1
vote
2 answers
Modify weighted graph
I've written a code to traverse an undirected non-weighted graph. Now i want this code to work for weighted graph where weights will determine the distance between nodes and my code will give the shortest path between starting node and end node. I…

Harshal Sawant
- 27
- 4
1
vote
1 answer
Converting cyclic graph to acyclic in a weighted graph
I am given a connected, weighted graph, with non-negative weights. I want to convert it to a connected, acyclic graph such that sum of weights of the removed edges is minimised. The output would be the removed edges.
My thoughts: Since a connected,…

Ankit Kumar
- 1,145
- 9
- 30
1
vote
2 answers
How can I calculate global efficiency more efficiently?
I have created some code to calculate weighted global efficiency, however, the code is taking too long to run. I need to either make the code a lot more efficient or I need to find a more efficient way of calculating it for large data sets (up to…

Kas
- 21
- 3
1
vote
0 answers
How to create a confidence ellipse with weights?
I would like to draw a confidence ellipse (sometimes also called concentration ellipse) for two continuous variables using Stata.
There is a community-contributed command called ellip for this kind of graph, a detailed description of which is…

non-numeric_argument
- 658
- 7
- 25
1
vote
0 answers
Find minimum weighted path in a vector of tuples representing a graph
I am still new to graphs and am building a weighted directed graph for a school project. I was able to complete all the functions except the one that find the minimum weighted path from a node to another. I am able to find a path, but don't know how…

user3812411
- 342
- 3
- 17
1
vote
0 answers
How to find an optimal path for a double weighted graph?
Given a Graph which has vertices as Cities and Edges as the distance between the cities. Each and every city has certain number of holidays associated with it. Initially you are given the starting point. Now the goal is to find a path in a graph…

Ajantha
- 33
- 4
1
vote
1 answer
Mapping edgelists to an adjacency matrix (and sum them together)
I want to map a number of (undirected) friendship networks (in edgelist format) to an adjacency matrix consisting of all possible nodes (i.e., persons) using R. To begin with, I construct a smaller 4-person circle x <- c(1, 2, 3, 4) which consists…

Chris T.
- 1,699
- 7
- 23
- 45
1
vote
1 answer
How to find probability of predicted weight of a link in weighted graph
I have an undirected weighted graph. Let's say node A and node B don't have a direct link between them but there are paths connects both nodes through other intermediate nodes. Now I want to predict the possible weight of the direct link between the…

kumaran ragunathan
- 447
- 2
- 12
1
vote
1 answer
finding shortest cycle which includes a specific edge
Hi i wanted to solve "shortest cycle through a given edge " problem that is on this website http://rosalind.info/problems/cte/ .
suppose our specific edge (that is our first edge in this problem) be 'E'.
i wrote a program to solve this problem and…

Sia
- 11
- 1
1
vote
1 answer
PageRank for weighted graph issue
I have a question about how PageRank can show the impact of "weight". I want to calculate the PageRank of trade countries using the trade value as a weight, my code is shown below. But what I find is that the results are same as the results that are…

Skye
- 11
- 2
1
vote
1 answer
Python networkx weighted graph not taking into account weight of node in shortest path calculation?
I'm using Python 3 and Networkx 1.11.
I make a weighted graph, with weights on the edges and some nodes, but when I calculate the weight of a shortest path, the weight of the node is not taken into account (code below).
Anyone know how to ensure…

Sam Short
- 183
- 1
- 1
- 9
1
vote
1 answer
Weighted graph fatness algorithm
Consider a connected weighted directed graph G = (V, E, w). The fatness of a path P is maximum weight of any edge in P.
How to find the minimum possible fatness of the graph? Could Dijkstra's algorithm be used to find the minimum fatness?

Alviss Min
- 79
- 10