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 …
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…
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…
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…
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…
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…
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,…
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…
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):
…
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…
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…
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 =…
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?
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…