Questions tagged [undirected-graph]

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

Definition of an undirected graph.

271 questions
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
  • 147
  • 1
  • 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
  • 127
  • 1
  • 2
  • 10
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
  • 373
  • 2
  • 11
2
votes
1 answer

Why is a binary tree an undirected graph?

In a binary tree, each parent has a reference to its child nodes. There is a direction from each parent node to each of its child node as shown in the tree image below. So how come it is defined as an undirected graph? One more question I have…
kaka
  • 597
  • 3
  • 5
  • 16
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
  • 41
  • 1
  • 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
  • 145
  • 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,248
  • 10
  • 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
  • 3
  • 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
  • 441
  • 2
  • 7
  • 19
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
  • 2,034
  • 7
  • 34
  • 61
2
votes
2 answers

Remove cycles from connected graph by finding vertices and edges

How can I remove all cycles from a graph like this? All edge lengths are one, and all edges are either vertical or horizontal. The graph is connected. I want to compute the smallest number of edges that have to be removed in order for the graph to…
Bob Billy
  • 285
  • 1
  • 6
2
votes
1 answer

Depth first Search more than one solution

I have this maze which represented as undirected graph. Here's how it looks like: 11 3 2 3 0 3 1 4 5 4 5 7 6 7 7 8 8 9 9 10 6 11 7 11 In this graph, with the use of depth-first search and it shows me a solution from start node to goal node. My…
1 2
3
18 19