I was trying to detect a cycle in a directed graph.
While coming up with the logic to solve it, I figured out that a simple graph traversal eq. dfs is sufficient because while doing dfs we can just have a condition to see if any node is already…
I recently solved a problem of the longest path by using BFS twice. I also learned that dynamic programming can be used to solve the longest path in a directed acyclic graph. What would the pseudocode and recursion equation/runtime be for finding…
A request from a noob Java beginner. I know it's a naive question, but till now I haven't found a satisfying solution. Some of the posts on stackoverflow currently either are for unweighted graphs, or involve complicated graph implementation work.
I…
There are [N] locations in a town labeled 1....N. You are provided a list of streets S (|S| = M) where a single street connects two locations in the town and has an associated distance. You also provided a list H of houses in the town and a list C,…
I want to group non-connected vertices in a graph and minimize the number of these groups. In another word, given a collection of vertices, divide them into minimum number of groups but at the same time no two connected vertices in the same…
I have an exercise for university where I have to write an extended DFS algorithm.
Based on the DFS, I have to specify a procedure that traverses an undirected, continuous graph, classifying each node according to whether it is part of a cycle or a…
According to GeeksForGeeks, the steps to find Minimal Spanning Tree in an undirected graph are :
Sort all the edges in non-decreasing order of their weight.
Pick the smallest edge. Check if it forms a cycle with the spanning tree formed so far. If…
I'm analyzing a large graph (382 219 nodes, 15 038 083 edges) with 1 721 connected components. One of these components has 374 511 nodes and 15 014 839 edges. Since I don't have the resources (CPU & RAM) to analyze such a large graph I decided to…
I am having issues with a graph implementation using an adjacency matrix. As a little background, I have to read from a file each line containing an actor, a movie they played in, and the year it was made. My job is to create a graph from the file.…
I was recently given an assignment that requires the need to construct an undirected unweighted graph in order to later on use it in a BFS algorithm. For some background, the adjacency matrix stores vertexes in string form, and its edges in string…
I have an undirected graph which gets loaded as an adjacency matrix. I have a method to detect a cycle in a graph using BFS algorithm. What I am trying to achieve is to print all the edges in a way that they indicate a cycle which has been found.
I…
I need some help, I'm trying to create an adjacency list to represent a graph in C, I can add one edge to each node list, but I have no idea how to add more than one, I also dont know how to delete an edge , this is what I've got
edit 1 * I create…
How to find in undirected, weighted graph the minimal eulerian path?(This path must contain the given edges)
The weight of the edges is the sum of the 2 points(exmpl:edge 4-9 weight=4+9=13) for all edges.
example:
With 6 nodes(N),and with 5…
I am creating a graph with 5 nodes in it (A,B,C,D,E) and edges/weights ("A","D",1),("D","B",3),("E","D",5),("C","B",4),("B","E",2)
I want to create a function that will create edges AB,AC,AE,BC,CE for me by summing the edges along the path from (for…