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

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
  • 103
  • 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
  • 669
  • 1
  • 10
  • 17
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
  • 109
  • 1
  • 2
  • 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
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
  • 901
  • 2
  • 10
  • 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
  • 353
  • 1
  • 5
  • 15
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,288
  • 15
  • 25
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!
LHA
  • 9,398
  • 8
  • 46
  • 85
-1
votes
1 answer

How do I find the shortest path from each node to any other specific node using R programming language in undirected graph?

Given a list of undirected and unweighted edges in an R dataframe(called edges_df, in which each row of the data frame contains id, start_x, end_x, start_y, end_y); how do I find the shortest path from each node to any specific node, say node 3(node…