I have this simple code in Python 3 using igraph to return an edge which I have added to an undirected graph.
from igraph import *
g = Graph()
g.add_vertices(3)
g.add_edges([(0,1), (1,2)])
# display(plot(g))
edge=g.es.find(_source=1,…
Given an undirected graph with costs on edges, find the shortest path, from given node A to B. Let's put it this way: besides the costs and edges we start at time t = 0 and for every node you are given a list with some times that you can't pass…
So I want to store all the actors from a production in a graph. So from the input we will read like this:
Let N be the number of movies we read, for each movie we read: the name of the movie, on the next line would be the number of the actors (let…
I need to write a code which tells if a cycle is hamilton or not.
First i have two text files:
1.file :
First line contains the number of vertices and edges while the rest is a pair of two vertices which are connected.Like 0 1 means there is…
I got a question in a contest(which is ended weeks ago). The question as I interpreted was -:
Given an undirected acyclic graph which is connected by (N-1) edges
and N nodes. The graph is guaranteed to be connected. Given two nodes
u and v, you…
I am using depth first search on an undirected graph to find paths from a starting node to an ending node. All the nodes along the path are stored in an ArrayList. But since there can be multiple paths going from start to end, I decided to store…
I found this algorithm that shows me just one hamiltonian cycle but I need to print all hamiltonian cycles in an undirected graph.
Here's the code that I tried to use: https://www.geeksforgeeks.org/hamiltonian-cycle-backtracking-6/
Could someone…
I am trying to represent a non-directional graph. I created three structs as shown below. I added operator == and operator < to the Edge struct hoping the set would use it to compare elements.
struct Node; /* Forward references to these two types…
TL;DR: I have a bunch of tetrahedra and I want to know which are its 4 (or less) neighboring (face-sharing) tetrahedra and I do that by checking the points in 3D that they share. This is slow.
I am building a connected graph from a triangulation.…
I have 122 nodes and I want to create a random graph, with node degree being fixed for each node. Is there any way to do it in R? I tried igraph, where I can fix the same degree for all nodes i.e. each of the 122 node will have a degree of 2. But, I…
I have a data structure that looks like a graph of rather isolated undirected "subgraphs" and would like to get those subgraphs that have less than N edges, in this case only those with one or two edges. I'm a bit lost here and am not sure how to go…
I'm working with a very large undirected graph (email networks for a company).
I’m bit confused about selecting the best and suitable technique of undirected graph of email networks. In that network, the vertices represent email addresses and an…
I'm trying to learn Prolog by solving Advent Of Code puzzles, and have ended up being stuck on a task that I think should be pretty simple. The puzzle in question is this one. The task requires me to find all program IDs (integers) that are…
There is an undirected graph G = (V, E), how can I assign each edge a direction so that every vertex has in-degree at most one in O(V+E) time?
There should be 2 conditions:
Situation 1. G has no cycle
What should I use? BFS or DFS, and…
I have an undirected graph and i'd like to find all the possible paths in it connecting all the nodes of a given set.
Is it an NP problem? Is there an algorithm to doing it, or a good way to accomplish it? I don't care about the order by which each…