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
1
vote
1 answer

Error in implementing BFS to find the shortest transformation from one word to another(Word Ladder Challenge)

I am trying to implement the word ladder problem where I have to convert one word to another in shortest path possible.Obviously we can use the breadth first search (BFS) to solve it but before that we have to first draw the graph.I have implemented…
Souvik Ray
  • 2,899
  • 5
  • 38
  • 70
1
vote
1 answer

Linked List generic array creation error undirected graph Java

so I'm trying to look for paths in an undirected graph using java. I feel like I'm maybe on the right track, pretty close to getting it, however, I keep running into a road block and get an error saying. I am using linked lists to store edges and…
1
vote
1 answer

Is an undirected graph the same as a directed graph if every node has edges going both ways?

If I have an unweighted directed multigraph where, for every edge going from node1 to node2, there is an edge going from node2 to node1, does that mean can be treated as un undirected graph? To give context, I am modelling a metro system where…
Ewan Brown
  • 143
  • 1
  • 9
1
vote
1 answer

Transform directed graph into an undirected graph and adding the weights

I have a directed graph where agents move from node1 to node2 like the following node1 node2 flow A B 12 B A 6 C A 1 D B 3 E A 4 A E 10 E B 1 B E 2 I would like to change this directed graph into an undirected one, summing the flow between edges,…
Felipe Alvarenga
  • 2,572
  • 1
  • 17
  • 36
1
vote
1 answer

Cost of undirected graph

Well, i got an undirected graph which looks like this. Each block represents an antenna (in a wireless phone network) and the black line splits the thing into different regions. We have some facts like: region(r1, 2110, [1,2]). region(r2, 2210,…
Alator
  • 497
  • 6
  • 23
1
vote
1 answer

Number Of Cycles In a Undirected Graph

The problem is as the title suggests, the graph is given in Adjacency List Form. My approach is to call DFS in any one vertex and whenever I hit a visited vertex during my DFS recursive step I increment the counter of a global variable starting from…
Akash
  • 939
  • 1
  • 8
  • 27
1
vote
1 answer

Finding vertices of a undirected graph that are connected in second graph

If I have an undirected graph, G = (V, E), and I want to find the subset S of vertices in G such that all the vertices in S have at least n connections to other vertices in S. What would be the best way to do this?
Timothy Tran
  • 91
  • 3
  • 9
1
vote
2 answers

Floyd-warshall for longest distance for undirected graph

I want to find the largest distance between any two vertices of a weighted undirected graph using Floyd-warshall algorithm. For this i have made few changes: I add negative weights instead of positive. Then i find out the shortest path. But it…
1
vote
1 answer

How to tell if an edge is on some path

Given an undirected graph G=V,E, 2 vertices: x, y and an edge e, I would like to check if there is a path from x to y that contains the given edge e. What I thought: Solve this by defining a network flow where x and y are source and sink and check…
wannabe programmer
  • 653
  • 1
  • 9
  • 23
1
vote
2 answers

Undirected graph abstraction

I have an undirected weighted graph and I need to formally describe it. Abstraction via automata or labelled transition systems seems to be not defined for undirected graphs, only directed graphs are covered. States within the graph are dependent on…
1
vote
1 answer

Project Undirected Cyclic Graph Onto Coordinate Plane

I have a collection of rooms, each of which is connected to one or more other rooms via the cardinal directions (north, south, east, west). The rooms have been connected in such a way that if A is west of B, then B is east of A; thus undirected…
Taylor
  • 51
  • 5
1
vote
5 answers

Efficiently obtain the graph from given facts

I have a set of points in 2-D plane(xy) say n points. (x1, y1), (x2, y2), (x3, y3), ......................., (xn, yn) My objective is to draw a graph. Two nodes(points) in the graph will be connected iff abs(difference in x coordinate) +…
cryptomanic
  • 5,986
  • 3
  • 18
  • 30
1
vote
2 answers

Do connected graphs with more than N-1 edges always contain connected graph with N-1 edges?

We know that: If we have N vertices To build a connected undirected graph, you'll need at least N-1 edges. Let M be the set of possible connected undirected graphs with N-1 edges. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Can we…
NL3294
  • 984
  • 1
  • 10
  • 27
1
vote
1 answer

How to check if there is a transitive orientation for a given undirected graph?

An undirected graph has a transitive orientation if its edges can be oriented in such a way that if (x, y) and (y, z) are two edges in the resulting directed graph, there also exists an edge (x, z) in the resulting directed graph. I am working with…
1
vote
0 answers

Having trouble with edges in an undirected graph for adjacency list C

I've been trying to create an Adjancey List with an undirected graph. Everything is going smoothly, except for when I need to have a Node(or vertex as in my code) have multiple edges connected to it. I have 6 vertexs A,B,C,D,E,F and there's only…