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

Mapping obstructions coordinates in 2D to undirected Lattice graph

Context: I want to do shortest path search for a mobile detector, source system operating in 2D Cartesian coordinates i.e. a 20 m x 10 m space. Using igraph for python, I have created a Lattice graph over these dimensions with vertices corresponding…
pproctor
  • 101
  • 1
  • 10
1
vote
0 answers

How to make my algorithm depends on time?

I used MATLAB to simulate the cascading failure of two interdependent networks/Layers (I generated the two layers based on small world - watts strogatz algorithm). My code works fine but it is not time dependent. I want to have time steps, for…
1
vote
1 answer

Can we turn any undirected graph into a directed one such that the difference between in- and out-degree of each vertex is at most 1?

Given any undirected graph G, is there always a way to add directions to its edges such that the difference between in-degree and out-degree of each vertex is not greater than 1? Consider for instance G is defined by vertices 1, 2, and 3, and…
1
vote
1 answer

Adjacency List in C for undirected (unweighted) graph

Here is my code: #define V 5 typedef struct edge* link; //structure for reprenting edges typedef struct edge{ int dst; //number of destination node //int weight; //for weigthed graphs link next; //link to next edge }…
Mad Tom
  • 15
  • 4
1
vote
1 answer

Print all minimum paths between 2 nodes in an undirected weighted graph

Given an undirected weighted graph, the lengths between 2 nodes are integers. How can one print the pair of nodes that have the minimum distance in the graph. If there are multiple pairs, print all of them
1
vote
1 answer

The first DFS path using a itertaive DFS rather than a recursive one

I am trying to implement a simple Dfs path finding for a problem in which I have to print the very first path I encountered and nothing if no path is found. I was able to do it with Recursion but i am having trouble with the iterative version. here…
1
vote
2 answers

Coloring of undirected graph

Given an undirected Graph with e number of edges and colour value m. So, that we have to check whether the graph can be coloured with m different colours with the condition that no two adjacent vertices are in the same colour. I have a thought…
1
vote
0 answers

Building weighted undirected graphs with SNAP library

I have been tasked with building & visualising a graph network consisting of hundreds of millions of nodes and billions of edges.I found snap library very useful for this purpose as it is developed for handling same situation. The graph should be…
nik
  • 11
  • 2
1
vote
1 answer

Detecting a cycle from tree's roots in an undirected graph

i want to determine if a given graph has the structure i want. The structure i want is that if the given graph's tree's roots form a cycle then the output is true, else is false. Here’s an example graph: It has 3 trees and the roots 1,5,4 form a…
george_pap
  • 23
  • 4
1
vote
2 answers

How to access attributes of a class instance which is a graph node via the graph?

Class definition: class Blah: def __init__(self,x): self.x = x Part of main(): (imported networkx) G = networkx.Graph() H = [] for i in range(1,5): H.append(Blah(i)) for i in H: G.add_node(i) Now, if I want to print H[2].x…
1
vote
1 answer

How to find the MST of a Graph in |V| Time given a spanning tree plus another edge

I'm wondering how to go about solving this problem. I'm given a graph G = (V,E). This is a connected undirected weighted graph. The graph consists of a spanning tree and one additional edge. How would I come up with an algorithm that would compute…
1
vote
0 answers

networkx undirected graph - weakest edges connecting the biggest nodes

Looking for some help on python networkx i have a dataset of about 20k shared mailboxes and 60K email ids. 1 email id can be in multiple mailboxes. i ran network graph which basically linked all connected email ids (by mailboxes) to form clusters.…
A_K
  • 81
  • 2
  • 10
1
vote
0 answers

Ancestral Sampling vs Gibbs' Sampling / Monte Carlo methods

So I recently started learning about Probabilistic Models and it is pretty confusing to me. My understanding is that ancestral sampling makes one pass through a directed pass, conditioning a sample of one variable on previous variables, while Gibbs'…
1
vote
1 answer

Finding all bridge edges in an undirected graph? (Code not working)

I am learning about bridges in graphs. I have the following C# code (also available in a fiddle - https://dotnetfiddle.net/XQEEdy): using System; using System.Collections.Generic; public class Program { public class Graph { private…
1
vote
1 answer

Julia module for subgraphing a graph (nodes / vertices and edges) without changing or relabeling node indices?

Terminology note: "vertices"="nodes", "vertex/node labels" = "indices" LightGraphs in Julia changes node indices when producing induced subgraphs. For instance, if a graph has nodes [1, 2, 3, 4], its LightGraphs.induced_subgraph induced by nodes…
JoseOrtiz3
  • 1,785
  • 17
  • 28