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

How to remove inverted edges in undirected graph in matlab

I have a edge list as cell array ['a' 'b','c' 'b','b' 'a'] I have been trying to generate a graph in MATLAB using G=graph(s,t) but I get an error for duplicate edges which i figure is because of [a b] and [b a]. I am not able to remove those in my…
Anurag
  • 21
  • 4
1
vote
2 answers

Find out largest subset of an Undirected Graph

Input: a list of vertexes and an adjacency list. Output: largest subset of good vertexes. (We say a vertex in a subset as "good vertex" if it has at least 2 adjacent vertexes and at least 2 non-adjacent vertexes in that subset.) Example…
Deqing
  • 14,098
  • 15
  • 84
  • 131
1
vote
1 answer

Write a Graph into a file in an adjacency list form [mentioning all neighbors of each node in each line]

I need to write a graph in a text file where each line of the file is composed from one node followed by all its neighbors. It's basically what an Adjacency List is, and what the function write_adjlist is supposed to do. Unfortunatly it's not the…
Simon C.
  • 1,058
  • 15
  • 33
1
vote
2 answers

What is the minimum number of edges that an undirected graph with n vertices must have for it to always be connected?

I know that for an undirected graph with n vertices to be connected it must have n - 1 edges. However, my question is what is the minimum number of edges that it can have for it to always be connected. For example, does a graph with n vertices and n…
Tim Mcneal
  • 283
  • 4
  • 19
1
vote
1 answer

Can an undirected graph with n vertices and n - 1 edges not be connected?

I know that for an undirected graph with n vertices the minimum number of edges it must have for it to be connected is n - 1. However, if a graph has n vertices and n - 1 edges, is it always connected?
Tim Mcneal
  • 283
  • 4
  • 19
1
vote
0 answers

Breadth-First Search (BFS) Using only a List of Available Functions

My question is mostly algorithm-related and not specific to a specific programming language Assuming we have a graph represented by a list of lists, where each internal list represents two nodes and a numbered edge, Is is possible to implement a…
Farzad
  • 1,770
  • 4
  • 26
  • 48
1
vote
1 answer

Trouble understanding some terms that have to do with undirected graphs

this is an example problem from an old midterm: Let G = (V, E) be a connected undirected graph where the edges have positive integer edge weights associated with them, and a vertex s ∈ V is the source. Provide an algorithm that for each vertex t ∈ V…
1
vote
1 answer

scala: directed and undirected edges of Graphs

If a directed Edge is implemented something like: class EdgeImpl(origin: Node, dest: Node) { def from = origin def to = dest } then which is the difference for implementing an undirected Edge while when we create a new Edge we also have…
Valerin
  • 465
  • 3
  • 19
1
vote
1 answer

Return Vertices In Undirected Graph

I am trying to come up with a greedy algorithm in Python that returns the vertices in an undirected graph given a certain starting vertex. I understand that DFS determines if a cycle exists, but I am trying to actually return the vertices that form…
steveclark
  • 537
  • 9
  • 27
1
vote
2 answers

Counting nodes in the largest cycle of an adjacency matrix

I am currently writing a program using an undirected graph. Im representing this by creating an adjacency matrix of the connections. if(adjacency_matrix[i][j] == 1){ //i and j have and edge between them } else{ //i and j are not…
Pseudo Sudo
  • 1,402
  • 3
  • 16
  • 34
1
vote
2 answers

How a given undirected graph could be made biconnected adding minimum number of edges?

I have a undirected graph which is connected. How could it be made biconnected adding minimum number of edges? I tried searching online for this particular algorithm and also tried thinking myself but couldn't figure out anything. Pseudocode would…
Amogh Antarkar
  • 129
  • 2
  • 16
1
vote
0 answers

R Printing closed circuits from an edgelist

I have an edgelist of an undirected graph structure. data <- data.frame(i = c("var1","var3","var5","var7","var7","var7","var11"), j = c("var2","var4","var6","var8","var9","var10", "var1")) head(data) i j 1 var1 var2 2…
puslet88
  • 1,288
  • 15
  • 25
1
vote
1 answer

Finding the cycle in an undirected graph using BFS

I want to find first cycle in an undirected graph using BFS only(NOT DFS). All sources solved this problem with DFS but I have to find it using BFS. How can I find it? Thanks in advance!
ninbit
  • 530
  • 6
  • 24
0
votes
0 answers

Branch and Bound function only returning first cycle in Python

This is my first question here as I've usually found helpful answers by searching previous posts. I cannot find any that relate to my particular problem this time. I need to complete a branch and bound function in Python (it's for a Coursera…
0
votes
1 answer

List of all possible path of edges between two nodes, showing edges multiplicity

I'm working on a algorithm that models a electric grid as a Undirected Multigraph so I can analyse the faults on the grid using python. I have the functions that get me all the minimum paths (paths that do not loop) between two nodes and need to get…