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
0 answers

How do I plot undirected graph and find path matrix from a source to destination node?

I have tried to plot a graph in MATLAB the following way as found on mathworks: s = [1 2 2 2 3 4 4 5 6 6 7 8 8 9 9 10 11 11 11 12 13 14]; t = [2 3 8 6 4 5 6 7 7 9 10 9 11 10 12 13 12 14 15 13 14 15]; G = graph(s,t) But it returns me Undefined…
Azhar
  • 23
  • 3
0
votes
0 answers

Merging possibilities in undirected graph

I need to create a matrix which constraints merging opportunities (presented in a integer vector). The merging opportunities are defined by adjacent nodes (i.e. connected by an edge) in an undirected network. As an example, consider this undirected…
Nico
  • 1
  • 1
0
votes
1 answer

How to convert from an immutable set to a hashset?

I am writing an algorithm to set up an undirected graph of objects. After adding and removing edges correctly to specific elements in the graph, I reach a certain point where I get this error. Exception in thread "main"…
matrix66
  • 3
  • 1
  • 2
0
votes
1 answer

igraph to_undirected() method analogy in NetworkX

In igraph I found two different methods for converting graph to undirected graph: The first is to_undirected which simply 'Converts a directed graph to undirected.' and the second is as_undirected which invokes to_undirected on the copy. In…
Demyanov
  • 831
  • 1
  • 9
  • 15
0
votes
2 answers

Algorithm for path in an undirected graph between 2 points

Suppose we have an undirected graph, and two nodes A and B. I need to write a method to find a path without cycles between A and B. All edges of this graph have the same weight. The method must terminate as soon as it finds such a path. How can I…
boris
  • 343
  • 4
  • 12
0
votes
0 answers

Algorithm to maximize number of traversed nodes

I'm trying to optimize a graph-traversal problem, but can't figure out the best way to tackle it. It seems neither like A* search problem (because we want to maximize the path rather than minimizing it), nor traveling salesman problem (because we…
0
votes
1 answer

Boost Graph Library undirected_graph: how to specify the vertex type (e.g. as int)?

is it possible to fix the type of the vertices in a boost::undirected_graph such to be, e.g., 'int'? The 'int' vertex type seems to be the default with the boost::adjacency_list, and the following code works: boost::adjacency_list< boost::vecS, …
yamiddu
  • 43
  • 1
  • 6
0
votes
2 answers

R ratio of element pairs between datasets

I have a data frame that contains the pairs of elements found in a number of datasets. The order of pairs should not matter, they are given once by alphabetic sequence, however the first instance may differ between databases, as in the example. data…
puslet88
  • 1,208
  • 13
  • 24
0
votes
1 answer

How do i add an Edge to a graph which is a List>?

I have aList< List< int> > graph; I have used it for representing an undirected graph. When i add a new edge graph[u].Add[v];, I am unable to itertate for a specific graph[u].
js-ninja
  • 3
  • 1
0
votes
2 answers

Longest path (edge weight = 1) in Un-directed graph solution?

I have an un-directed graph that weight of each edge is 1. The graph may have cycles. I need to find a longest path in the graph (each node appear once). The length of the path is number of nodes. Any simple/effective solution? Thanks!
Loc
  • 8,364
  • 6
  • 36
  • 73
-1
votes
1 answer

Determine if the graph is directed or undirected

Can anyone offer some suggestions on how to write a method that returns if a graph is directed or undirected in python? Thanks. class DiGraph : def __init__ ( self ) : self._adj = {} def add_node ( self , u ) : if u…
-1
votes
1 answer

find cycles of length 4 in undirected graph

I'm looking to print the found cycles of length 4, this code helps me correctly count the number of cycles but I also wish to print those cycles for example in this particular input graph the cycles are: 0 -> 1 -> 2 -> 3 -> 0 0 -> 1 -> 4 -> 3 -> 0 1…
-1
votes
1 answer

Any efficient algorithm to find all cycles in an undirected graph?

I'm trying to find all cycles in an undirected graph and didn't find any algorithm for the same in any online sites / geeksforgeeks. There is one for directed graph (Johnson algorithm), but it isn't working (desired o/p) on undirected. Any…
user12318711
-1
votes
1 answer

Creating undirected weighted graph from adjancency matrix from a csv

I want to create undirected weighted graph of a given adjacency matrix by reading it from a csv. I can read it from a csv but I don't know how to draw its in graph. This is code for reading file. int main(){ ifstream ip("map.csv"); …
shahid hamdam
  • 511
  • 5
  • 17
-1
votes
1 answer

how to check presence of cycle in undirected graph?

#include using namespace std; int n,m; vector adj[51]; int visited[51]; bool flag; void dfs(int i,int parent){ vector::iterator it; for(it =…
1 2 3
14
15