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

Topological sort on directed and undirected graphs using DFS algorithm

I can determine the topological sort of a directed graph using DFS algorithm. If there are no cycles, I assume the topological order I found is valid. If there is a cycle, I assume the topological order is useless. Am I correct so far? What about…
Mehmed
  • 2,555
  • 4
  • 32
  • 55
5
votes
1 answer

Finding equally-sized mutually exclusive complete subgraphs within a graph whose union is the entire graph

INPUT Undirected graph G with n vertices and an integer k such that k divides n. The set of all vertices will be denoted by V. OUTPUT A set S of sets of vertices such that: S has k elements Each element of S is a complete subgraph in G (all…
4
votes
0 answers

Calculating a threshold based on the connectedness of a weighted graph

Given a matrix like the one that follows (but a lot bigger) that describes a weighted undirected graph, structure(list(from = c("TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1",…
J. Doe
  • 581
  • 3
  • 13
4
votes
3 answers

Numpy- get neighbors matrix from 2D array

I have a undirected graph given by: A,B A,C A,F B,D C,D C,F E,D E,F And I need to transform this to a matrix N where N[x,y] = 1 if x is neighbor of y (like A and B) and 0 if not What is the fastest way to do it? NOTA The graph is stored as numpy…
farhawa
  • 8,406
  • 16
  • 37
  • 80
3
votes
0 answers

Is there any module available in Erlang to find all the cycles of an undirected graph?

For a directed graph, we have the following module: digraph_utils:cyclic_strong_components(G) Is there anything like this available for undirected graphs in Erlang? I want to find all the cycles in an undirected graph. Is there a method by which I…
3
votes
1 answer

Finding maximum number of nodes in set of undirected graphs

I have a set of nodes (N=7) {a, b, c, d, e, f, g} These nodes form one or more distinct undirected graphs, I want to find the graph with the maximum number of nodes. However, I have a constraint that the complexity can not be more than (N*M) where…
3
votes
1 answer

How to compare edges in a graph to implement a triadic closure like in network graphs like facebook

I am trying to implement a graph that contains Vertices(nodes) that relate to a Profile class(like a Facebook profile but more mediocre). Each of the vertices(Profiles) is stored in a Binary Search Tree which is then loaded or stored in an…
3
votes
3 answers

Find the reverse direction edge and subtract its weight from its oposite

I'm having a matrix like the following one m <- expand.grid(LETTERS[1:24],LETTERS[1:24]) m$weight <- runif(nrow(m), 0.01, max = 1) m <- m[m$Var1!=m$Var2, ] ##remove loop edges colnames(m) = c("to","from","weight") and in this form it describes a…
J. Doe
  • 581
  • 3
  • 13
3
votes
2 answers

Count number of nodes in each connected part of an undirected unweighted graph

I am new to C++ STL and have started Graph Theory recently. After referring to https://www.geeksforgeeks.org/connected-components-in-an-undirected-graph/, I can count the number of connected components in an undirected, unweighted graph using DFS…
Tanya Sethi
  • 33
  • 1
  • 8
3
votes
2 answers

Prove upper bound of O(log n) on the maximum outdegree of an undirected graph turned into a directed one by this algorithm

Some definitions first: an "accumulated graph" is a graph where edges are added to it later on. The topic is orientation problem (making an undirected graph directed), when our goal is to make the maximum out-degree the lowest possible. Now, they…
John Smith
  • 53
  • 1
  • 8
3
votes
2 answers

Prove a property of Minimum Spanning Tree

I need your help proving the following: G=(V,E) is an undirected connected graph with non-negative weights on the edges. Let T be a MST of G and T' be a spanning tree of G (not a minimum one) so it holds that Weight(T') > Weight(T). Prove that the…
Noam
  • 1,329
  • 2
  • 20
  • 42
3
votes
1 answer

How can I find bridges in an undirected graph?

Given an undirected Graph, how can I find all the bridges? I've only found Tarjan's algorithm which seems rather complicated. It seems there should be multiple linear time solutions, but I can't find anything.
Jakub Arnold
  • 79,807
  • 86
  • 218
  • 314
2
votes
1 answer

How to find if a path exists between two given vertex JAVA

Im trying to write a method to find whether or not a path exists between to vertex in an undirected graph that is representned in an adjacency matrix. This is the adjacency matrix that I have: int[][] adj_matrix ={{0,1,0,0}, …
2
votes
1 answer

Largest empty subgraph of an undirected graph in SWI Prolog

An undirected graph is given. Find the number of internal stability of the graph. That means finding the power of the largest empty subgraph. (The empty subgraph is one with no vertices directly connected by edges). I set the edges and vertices.…
2
votes
2 answers

Algorithm to find any two nodes with distance of at least half the (undirected) graph's diameter

I have to give an algorithm as follows: Given an undirected connected graph G, give an algorithm that finds two nodes x,y such that their distance is at least half the diameter of the Graph. Prove any claim. I'm assuming I have to run a BFS from any…
SaraH
  • 25
  • 6
1
2 3
14 15