Questions tagged [undirected-graph]

An undirected graph has edges which have no orientation. It is a mathematical concept.

Definition of an undirected graph.

219 questions
2
votes
1 answer

Single source shortest path using BFS for a undirected weighted graph

I was trying to come up with a solution for finding the single-source shortest path algorithm for an undirected weighted graph using BFS. I came up with a solution to convert every edge weight say x into x edges between the vertices each new edge…
2
votes
1 answer

"sna" or "igraph" : Why do I get different degree values for undirected graph?

I am doing some basic network analysis using networks from the R package "networkdata". To this end, I use the package "igraph" as well as "sna". However, I realised that the results of descriptive network statistics vary depending on the package I…
Edda
  • 23
  • 2
2
votes
1 answer

Counting undirected edges between any two nodes

I'm trying to generate an edge list to feed into R's igraph plotting function, which requires that I generate a data.frame' objective consisting of two columns representing "from" node and "to" node with other columns serving as edge…
Chris T.
  • 1,181
  • 3
  • 17
  • 32
2
votes
0 answers

Optimising dijkstra algorithm for particular problem

Imagine we have some cells, and you can teleport in other cells through portals, there exists some "teleporting" time for every cell, but there are also some guardians, while a guardians is in the cell you're in you have to wait until the moment he…
J. Homer
  • 157
  • 11
2
votes
1 answer

s-t cut for undirected weighted graph

I recently got interested in graph theory. I came across the s-t cut for a directed graph. I learned online that the min-cut is equal to the max flow and there are standard algorithms out there that can solve the s-t min cut for a directed graph.…
2
votes
2 answers

DepthFirstSearch java implementation

I am trying to learn how to implement graphs (Depth First Search) into java. And here is a piece of code that I do not understand what a character means in here. It is about this piece of code: private void dfs(Graph G, int v) { count++; …
Jay Dee
  • 117
  • 8
2
votes
0 answers

Finding a path from start to end by traversing a graph

I am currently doing a school assignment that wants us to model a bus route map using graphs (undirected), where the edges represent roads which has labels set to the bus route letter (one road may have have bus a, but another may have bus b) and…
Pengibaby
  • 353
  • 1
  • 7
2
votes
1 answer

Is this the best algorithm for detecting a cycle in an undirected graph?

The following C# algorithm I wrote detects the existence of a cycle in an undirected graph in O(n) time. It avoids recursion and takes advantage of hashing via Dictionaries and HashSets. But is there a way I can do even better? void Main() { …
2
votes
0 answers

Connecting line segments to create closed regions

I am working on the problem of trying to segment an image based on straight edges to try to get closed quadrilaterals. I have been able to extract line segments using an edge detector. Is there a good way to connect edges that would be "nearly…
2
votes
2 answers

Sub-Tree of Shortest path Tree is also a shortest Tree?

I have an undirected weighted graph G=(V,E) where V represent nodes and E represent edges. Through Dijkstra Algorithm, I got a shortest path tree Ts=(s,V) rooted at source node s and spanning all nodes V in the graph G. Then I selected a sub-tree…
Ali
  • 21
  • 5
2
votes
2 answers

Find all subsets of a finite metric space for which the sum of distances is less than a given number

I have five elements A, B, C, D and E. The distance between each of the elements is given by the matrix below: Distances = [0 5 3 8 15; 5 0 7 5 20; 3 7 0 12 12; 8 5 12 0 8; 7 20 12 8 0] I want…
Abhijith N
  • 125
  • 1
  • 1
  • 6
2
votes
2 answers

On a weighted directed graph of unknown size, how can one iterate over all possible acyclic paths between two vertices from shortest to longest?

We can assume that all edge weights are positive, and that you can enumerate the edges leading outwards from a vertex, and likewise the edges leading inward, in O(1) time. For example, you can perform Dijkstra traversal (or A*, with an admissible…
Mumbleskates
  • 1,089
  • 8
  • 18
2
votes
2 answers

Python iGraph labels cutoff

I'm testing igraph python to plot undirected graph. The problem is that the labels get cuttoff for some reasons. The labels contain spaces, so I had to replace the spaces with underscore. For examples: If the label is Mike_Jorden then only e_jorde…
MikeAlbert
  • 164
  • 2
  • 11
2
votes
2 answers

Breadth-first-search on 2D array

I have a grid of connected paths as shown below: The grid is a 2D array created as follows: for(var x = 0; x < 10; x++){ hz[x] = new Array(10); for(var y = 0; y < 10; y++){ hz[x][y] = new block(0, 0, 0, 0, 0); …
ALR
  • 401
  • 2
  • 7
  • 18
2
votes
1 answer

how to use Dinic's algorithm to find min-cut edges in undireted graph?

I am looking for an algorithm, when a given two nodes 's' and 't' in a undiredted graph, to find min-cut edges, which partitions the graph into two A and B, 's' will in A and 't' will in B. I see most people suggesting for Ford–Fulkerson algorithm…
arslan
  • 1,644
  • 4
  • 25
  • 51
1
2
3
14 15