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

pandas DataFrame edge list to networkX graph object

I am trying to create an undirected graph from a DataFrame formatted_unique_edges - the 'weight' column will purely be used for edge colouring in downstream visualisation using plotly: source target weight 0 protein_2 protein_3 …
Tim Kirkwood
  • 598
  • 2
  • 7
  • 18
1
vote
0 answers

Detect loops (including their nodes) in undirected graph

I'm looking for a way to detect loops (including the nodes that form them) in an undirected graph. This answer suggests that we can detect a loop during a depth-first-search "If an unexplored edge leads to a node visited before." So with the code…
Hoff
  • 38,776
  • 17
  • 74
  • 99
1
vote
0 answers

Which element(s) can I remove from a connected graph so that the graph remains connected?

So I'm making this code in C++ which is supposed to tell which elements from a connected graph can be removed so the graph stays connected, but I don't even know where to start. I was thinking of making a copy of the initial graph and try to remove…
Alex
  • 11
  • 2
1
vote
1 answer

Query check if there's a path between 2 nodes after an edge / node is removed

Question: Given an undirected graph with N nodes and M edges. Given Q queries, there are 2 types of query: 1 - A - B - U - V Check if there's a path between the node A and B after you remove the edge U-V 2 - A - B - X Check if there's a path…
unglinh279
  • 675
  • 4
  • 24
1
vote
1 answer

Count pair of nodes that can't reach each other if you for each deleted edge

Question: Given a undirected graph of N nodes and M edges. You need to solve 2 problems: Problem 1: For each edge j (j : 1 -> M), if you delete that edge, count the number of nodes that can't reach each other (there's no path between that 2…
unglinh279
  • 675
  • 4
  • 24
1
vote
0 answers

How do I linearize a quadratic problem about graph theory?

I need to solve a maxcut problem of a graph having 4 nodes and 5 edges, but I have to do it both with a quadratic solution and a linear one. I need to transform the quadratic maxcut problem to the linear one by adding some constraints but I have no…
1
vote
1 answer

Find the length of longest palindrome path in an undirected acyclic graph

The problem is: given an undirected acyclic graph (N nodes and N-1 edges), where each node is labeled with a character, find the length of the longest path of nodes in the graph that forms a palindrome. Suppose there are N (1 <= N <= 500 000) nodes,…
1
vote
2 answers

Fast Python algorithm for finding the path that maximize the sum of the changes of each move

Say I have a undirected graph (can be cyclic or acyclic), where each node is asigned with an integer state. I want to find the path that: goes through every node but only once doesn't need to go through every edge maximize the sum of the state…
Shaun Han
  • 2,676
  • 2
  • 9
  • 29
1
vote
1 answer

Implementing a graph without a library in Python

I'm new to Python and trying to build a directed graph without the use of a library. Can someone please confirm if I'm understanding this example correctly? from collections import defaultdict class Graph: def __init__(graph): …
henee
  • 21
  • 7
1
vote
1 answer

For an undirected connected graph, how create an index of the bridges maintained after removal of edges?

Creating an index itself is the same as computing the list of bridges. The question is about how to maintain that index after removing an edge without recomputing it altogether. Maybe storing the list of all (simple) cycles and removing all cycles…
galva
  • 1,253
  • 10
  • 17
1
vote
0 answers

Sort out the simple cycles from a list of all cycles in a undirected graph

I've created an undirected graph and extracted all the possible cycles inside it. I want just the simple cycles because I'm creating polygons from them. The problem is that I don't find an algorithm of how to do it. The following graph generates 6…
Teh Swish
  • 99
  • 1
  • 12
1
vote
0 answers

Is it possible to find the bias of connections for such a tree?

Any language is fine. I'm trying to determine if this is possible. Suppose there are N nodes that need to be connected together. There should exist a path between every pair of nodes. x creates i connections, and y creates j connections. The bias =…
1
vote
2 answers

UML undirected graph to UML directed graph

I was trying to change this UML (class diagram) undirected graph representation to a directed graph, but I got stuck. What are the changes that have to be made and why?
JavaStudentPanic
  • 47
  • 1
  • 2
  • 10
1
vote
0 answers

How many undirected graphs are there with N vertices, at least one vertex being isolated?

I got this qustion in a test, the answer says N * 2^((N-1)*(N-2)/2), because for each of the N vertices, it calculates the number of undirected graphs with N-1 vertices. But I think this answer is wrong. For N=3 it results 6, when, in fact, only 4…
1
vote
2 answers

Is there in SQL a way to enforce unicity of undirected edge?

create table Location ( id integer primary key(1, 1), latitude decimal(8,6), longitude decimal(9,6), address varchar(100), name varchar(60) unique ); create table Journey ( id integer primary key(1,1), id_from integer foreign key references…
Ludovic Aubert
  • 9,534
  • 4
  • 16
  • 28