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

Avoiding infinite recursion but still using unbound parameter passing only

I have the following working program: (It can be tested on this site: http://swish.swi-prolog.org, I've removed the direct link to a saved program, because I noticed that anybody can edit it.) It searches for a path between two points in an…
0
votes
2 answers

Convert a binary tree to corresponding undirected graph

Given a representation of a binary tree which can have the maximum of n nodes: typedef struct node { int info,n; struct node *left,*right; }tree_node; Construct an undirected graph from a binary tree which can have the maximum of n nodes. Graph…
ufo
  • 93
  • 1
  • 10
0
votes
2 answers

Make undirected graph from adjacency list

I'm trying to make an undirected graph from an adjacency list to practice the Karger's Min Cut algorithm. The following is my code class Vertex(object): '''Represents a vertex, with the indices of edges incident on it''' def…
Effective_cellist
  • 952
  • 1
  • 19
  • 35
0
votes
0 answers

Set of all pairwise matchings in an undirected, unweighted graph

So, I am relatively new to Python and programming in general. However, I have an undirected graph without weights. Some nodes are connected, some not. Some have just one connection, some will have multiple. Each node represents an individual that…
0
votes
1 answer

Undirected graph in Java with unknown number of vertices

I am trying to create an undirected graph in Java with a "live feed" of vertices. I have the vertices coming in from a txt file. The file is structured like this, 1 2 #connect node 1 with node 2 2 3 #connect node 1 with node 2 and so on. I have…
0
votes
1 answer

Unique paths undirected cyclic graph

I am working on a problem in graphs and trying to figure out on finding unique paths let me give an example, let us consider a graph with 4 nodes and 6 edges with edges as follows - 1 2 2 3 3 4 4 1 1 3 2 4 the unique cyclic paths of length 5 will…
joe bill
  • 1
  • 2
0
votes
1 answer

How can Dijkstra's algorithm apply to both undirected and directed algorithm in one program?

The graph is represented in the format as below: MAX 12 NODE 1 1 NODE 2 2 NODE 3 3 NODE 4 4 NODE 5 5 NODE 6 6 NODE 7 7 NODE 9 9 NODE 8 8 NODE 10 10 NODE 11 11 NODE 12 12 EDGE 1 2 EDGE 2 3 EDGE 3 4 EDGE 4 5 EDGE 5 6 EDGE 6 7 EDGE 7 8 EDGE 8 9 EDGE 9…
NUO
  • 207
  • 2
  • 3
  • 13
0
votes
1 answer

Most efficient algorithm to know if undirected graph is connected

I´ve been trying to find an algorithm to search if a graph is connected. The graph is undirected and I only want to find a solution (there can be multiple) or if there is none. I was looking for a alg. that performs near linear time, maybe O(logN)…
0
votes
1 answer

Using DFS in Adjacency list and using a pointer array of pointers

I am trying to create a C program that reads in an input file that contains a set of points representing edges of an undirected graph. I am trying to store each vertex struct in an array that is implemented using a pointer, however the array does…
0
votes
1 answer

Proper traversal of undirected graph using depth first search?

I've got an undirected graph that I need to traverse using depth first search. The excel chart below shows each node has been marked after traversal in the marked column, and the edgeTo column shows which node brought us to that node. For…
Omar N
  • 1,700
  • 2
  • 16
  • 28
0
votes
2 answers

How to group/List all nodes of a undirected graph using teradata sql

I have data for many diff. set of undirected graphs in a table (like adjacent list relationship, one node is connected which all node) and I need to group all individual undirected graphs. Eg: all nodes of the particular undirected graphs will be in…
0
votes
1 answer

Undirected Graph Issue

I generated this code to test a random undirected graph 100 times and randomly generating the nodes and weights of the graph. My problem is that when I try to store the shortest path by calling minimum distance something is going wrong and when I…
Daniel R
  • 73
  • 1
  • 5
0
votes
1 answer

igraph's Weighted_Adjacency mode argument

First, thanks for taking the time to read and respond. Second, the question: I am trying to form a weighted undirected graph from my symmetric adjacency matrix, A, where the ij-th element is the edge weight between nodes i and j: import igraph as…
JRun
  • 559
  • 1
  • 8
  • 16
0
votes
1 answer

The length of the Shortest Cycle in an Undirected Graph

I am given an algorithm that is supposed to find the length of the shortest cycle in an undirected graph with unit edge lengths. I have to show that the algorithm does not always work by providing a counterexample. I am having problems coming up…
user3055141
  • 99
  • 1
  • 8
0
votes
0 answers

How do I create a zero-one matrix out of all possible paths from source to destination node?

Suppose I have network with 4 nodes and 4 edges as shown below All possible paths from source node 1 to destination node 4 are {{A,C}, {A,B,D}} From these possible paths, I want to create a zero-one matrix, where number of rows represents the…
Azhar
  • 23
  • 3