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

Is there any way to construct undirected weighted graphs where the data is separated in vertices ,index followed by x & y coordiated

i want to construct an undirected weighted graph (as a python dict), where weight is the Euclidean distance between two nodes connected by edges given in the Mapdata.csv file. I cant find anything on google. please help me. I want python code for…
Imama Khan
  • 11
  • 1
0
votes
1 answer

Find maximal weight edge between two nodes in an undirected acyclic graph

We have a graph with N nodes and N-1 bidirectional edges(each edge has some weight w). Now we have to answer q number of queries. Each query gives two nodes u and v and maximum allowed cost at any edge x. If the individual edge weights of all edges…
prakasht
  • 448
  • 4
  • 16
0
votes
2 answers

Implementation of Shortest Path Graph in Python Class

Hi! I am new to Python and I am struggling for many hours so far with some problem regarding Shortest Path Algorithm implementation in Python. I am expected to solve some task about finding shortest paths (graph problem) among given persons, and at…
Rikudo
  • 25
  • 4
0
votes
2 answers

Unexpected error in testing and learning about graphs in C

I have recently started to study this particular book for algorithms and data structure SkienaTheAlgorithmDesignManual.pdf, from which I've heard a lot of praise not only on the Internet,but from my Algorithms Design teacher as well at college,and I…
Neri-kun
  • 173
  • 3
  • 14
0
votes
2 answers

Implementing undirected graph with adjacency matrix

I was trying to implement an undirected graph with adjacency matrix. The type of vertex value is integer. And I use double pointer to represent the adjacency matrix. The question is right after I inputed all the value of vertices as how I programmed…
Liu
  • 413
  • 4
  • 11
0
votes
1 answer

read undirected graph csv file in R with library statnet

I have a csv file which has 2 columns, the first and second column contain nodes, each row means the nodes of an edge of an undirected graph. I am new to R, and this is my code: library(statnet) dat <-…
Jun.W
  • 1
  • 1
0
votes
1 answer

Python 3: TypeError: 'int' object is not iterable on a list of string elements

I am trying to implement a graph data structure represented by an adjacency list. I am using a dictionary with the vertices as keys and each key can have one or several values. A value consists of a list containing another vertice that the…
binaryglot
  • 23
  • 1
  • 5
0
votes
1 answer

Printing the longest path in an undirected graph

I am using this code https://www.geeksforgeeks.org/longest-path-undirected-tree/ to find the longest path in an undirected graph. The code uses two times BFS search to find the longest path and then it outputs the start and end of the path and the…
0
votes
2 answers

Depth first search current implementation problem when I try to run it

I'm here trying to share my depth first-search (DFS) implementation. I'm trying to learn how can it traverse in a graph that is undirected, meaning that not all nodes are making into one graph, but two different ones. I was looking for the small…
0
votes
1 answer

Kth shortest path in undirected graph

Is there any way with polynomial complexity(or better than that) to get kth or k shortest path of an undirected graph? or can Yen's k shortest path algorithm modified for undirected graphs?
nagleria
  • 29
  • 5
0
votes
0 answers

Shortest Path with must pass nodes

I want to calculate the shortest path from source S to sink T. But the path must pass from node1 and then node2 at least once. Eg: S->...->node1->....->node2->....->T And i have to run shortest path algorithm only once (meanly,i am not allowed to…
0
votes
3 answers

Convert undirected graph to directed graph with specific condition

undirected graph is given which has M edges and N vertices we have to convert every edge from u-v to u->v or v->u such that indegree of every vertex is even.Which method or algorithm is suited for least time complexity.
0
votes
1 answer

Efficient way to find a path from start to finish

I am currently doing an assignment where we need to find a path from a node on an undirected graph, the start node, to the destination node without changing the type of edge (each edge is labelled with a letter) more than a specified amount of…
Pengibaby
  • 373
  • 2
  • 11
0
votes
1 answer

How to write a toString method for a weighted undirected graph in java?

I have written a class for the undirected graphs and a symbol table to convert edges from strings to numbers and vise versa but the two string method is not working as i get a stack overflow error. i have implemented a LinkedStack which is the same…
Red Eyez
  • 187
  • 3
  • 16
0
votes
0 answers

Big-O time to construct a graph from a list

If you are given a list containing information (i.e. each entry is a pair: (pair of nodes and an edge labeling)). How would go about constructing a undirected graph from the list and is it possible to achieve an O(m + n) running time, respective to…