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
0
votes
1 answer

In SQL can you enforce unicity of undirected edge using sum and product computed columns?

create table Location ( id integer primary key(1, 1), latitude decimal(8,6), longitude decimal(9,6), address varchar(100), name varchar(60) unique ); create table Journey ( id integer primary key(1,1), id_from integer foreign key…
Ludovic Aubert
  • 9,534
  • 4
  • 16
  • 28
0
votes
2 answers

logic for method to detect cycle in an undirected graph

I was trying to detect a cycle in a directed graph. While coming up with the logic to solve it, I figured out that a simple graph traversal eq. dfs is sufficient because while doing dfs we can just have a condition to see if any node is already…
0
votes
0 answers

Longest path in a tree using dynamic programming

I recently solved a problem of the longest path by using BFS twice. I also learned that dynamic programming can be used to solve the longest path in a directed acyclic graph. What would the pseudocode and recursion equation/runtime be for finding…
0
votes
1 answer

Efficient way to store weighted edges in Java?

A request from a noob Java beginner. I know it's a naive question, but till now I haven't found a satisfying solution. Some of the posts on stackoverflow currently either are for unweighted graphs, or involve complicated graph implementation work. I…
0
votes
1 answer

Dijkstra's Algorithm Letting All Vertices be Source

There are [N] locations in a town labeled 1....N. You are provided a list of streets S (|S| = M) where a single street connects two locations in the town and has an associated distance. You also provided a list H of houses in the town and a list C,…
0
votes
0 answers

Group non-connected vertices

I want to group non-connected vertices in a graph and minimize the number of these groups. In another word, given a collection of vertices, divide them into minimum number of groups but at the same time no two connected vertices in the same…
0
votes
0 answers

Finding and printing nodes in a cycle or in a dead end based on DFS in an undirected graph

I have an exercise for university where I have to write an extended DFS algorithm. Based on the DFS, I have to specify a procedure that traverses an undirected, continuous graph, classifying each node according to whether it is part of a cycle or a…
bhamam
  • 11
  • 1
  • 2
0
votes
2 answers

Can we use n(V) <= n(E) to detect cycle while using Kruskal's MST for an undirected graph?

According to GeeksForGeeks, the steps to find Minimal Spanning Tree in an undirected graph are : Sort all the edges in non-decreasing order of their weight. Pick the smallest edge. Check if it forms a cycle with the spanning tree formed so far. If…
0
votes
0 answers

How to generate a supergraph from small graphs?

I'm analyzing a large graph (382 219 nodes, 15 038 083 edges) with 1 721 connected components. One of these components has 374 511 nodes and 15 014 839 edges. Since I don't have the resources (CPU & RAM) to analyze such a large graph I decided to…
0
votes
1 answer

Question about adjacency matrix implementation

I am having issues with a graph implementation using an adjacency matrix. As a little background, I have to read from a file each line containing an actor, a movie they played in, and the year it was made. My job is to create a graph from the file.…
0
votes
0 answers

Question about implementing adjacency matrix in unconventional fashion

I was recently given an assignment that requires the need to construct an undirected unweighted graph in order to later on use it in a BFS algorithm. For some background, the adjacency matrix stores vertexes in string form, and its edges in string…
0
votes
1 answer

Print edges of a cycle in an undirected graph

I have an undirected graph which gets loaded as an adjacency matrix. I have a method to detect a cycle in a graph using BFS algorithm. What I am trying to achieve is to print all the edges in a way that they indicate a cycle which has been found. I…
kabugh
  • 305
  • 1
  • 9
  • 30
0
votes
0 answers

How do I add and delete edges from a undirected graph represented with a adjacency list in C?

I need some help, I'm trying to create an adjacency list to represent a graph in C, I can add one edge to each node list, but I have no idea how to add more than one, I also dont know how to delete an edge , this is what I've got edit 1 * I create…
drpopp
  • 1
  • 1
0
votes
0 answers

Find minimal cost of eulerian path,which is contain given edges in undirected graph(Algorithm)

How to find in undirected, weighted graph the minimal eulerian path?(This path must contain the given edges) The weight of the edges is the sum of the 2 points(exmpl:edge 4-9 weight=4+9=13) for all edges. example: With 6 nodes(N),and with 5…
0
votes
1 answer

Python graph method to auto connect edges

I am creating a graph with 5 nodes in it (A,B,C,D,E) and edges/weights ("A","D",1),("D","B",3),("E","D",5),("C","B",4),("B","E",2) I want to create a function that will create edges AB,AC,AE,BC,CE for me by summing the edges along the path from (for…