Recently I came upon the Johnson’s algorithm to find "elementary circuits" on a directed graph, which is really cool to me. I’m just implementing it from scratch in C++ following the original Johnson’s paper. I have a couple of doubts before going on. In the paper it’s clear to me what $A_k$ about adjacency, but ..

#### Category : graph-algorithm

I’m trying to figure out how to implement djiktra algorithm to find the shortest path between 2 unweighted graphs. The suggestion I got was to use 2 graphs one for the red color and one for the blue color.The cost is always 1 to travel but to access a red square while being blue you ..

I have a directed Graph data structure that implements the hits algorithm, to find the authority and hub values of each vertex in the Graph. I used a 2D vector for an adjacency matrix representation. I have two boolean values (iter_bound & err_bound)that are the stopping condition for the algorithm. I have the stopping condition ..

There are n cities and m possible roads and k temples. The cost of each road is given. Build roads with minimum cost such that each city has access to at least 1 temple. Note Input : There can be multiple roads(edges) between two cities. The first line contains n, m and k. And the ..

I can already find the "cost" of the tour with my code, but I would like know the tour that is being followed, for example my code is trying to find the lowest cost in this graph: but I want to know the tour, so ideally I would get either 1-2-4-3-1 or 1-3-4-2-1 both with ..

I’ve been trying to make this program save the vertices that make the cycle in the graph. But I’m kind of a newbie in algorithms and achieving that functionality seems a bit complex when using BFS. The code below successfully finds cycles, but the question is how to modify this code so I can print ..

I am trying to solve flight routs, in graph algorithms on CSES. CSES is a site the contains a collection of competitive programming practice problems. This I the problem I am trying to solve https://cses.fi/problemset/task/1196. The question is to find the K shortest routes from vertex 1 to n, in a given wheighted graph. For ..

So there’s an algorithm to find the minimum cash flow among people (ie: to find the minimum number of transactions among people ) (source :https://www.geeksforgeeks.org/minimize-cash-flow-among-given-set-friends-borrowed-money/) But the algorithm isn’t completely accurate Consider the following test case : enter image description here When you input this the output says that there must be 5 transactions however ..

The problem statement is to create a binary tree from a given array of numbers (‘val’) and letters (‘name’) in level-order fashion. The problem however, is that the array can also contain ‘-1 N’ entries, which means that particular Node should be left empty (NULL), and the level order filling should continue from the next ..

This is the algorithm of the nested loop using three-loop int i, j, k; for (i=1; i<=5; i++) { for (j=1; j<=i; j++) { for (k=j; k>=1; k–) { cout<<"*"; } cout<<"endl"; } } I want a flowchart for that nested loop. I want to run it manually, How do they work? Source: Windows Questions ..

## Recent Comments