#### Category : graph

Today while solving a question on leetcode, I applied dfs on a directed graph which runs on O(N) time, but my code is giving TLE, so after trying too many time I checked on comments and there was a accepted code which also runs on O(N). So now I am confused as why my code ..

How can I implement the greedy algorithm to get the full coloring of the graph? That is, not only color the adjacent vertices with different colors, but also color the edges with different colors of their vertices? Using as few colors as possible. As in the image below: Total coloring graph // A C++ program ..

i have created two functions for finding paths between two vertices in a adjacency matrix. first function countPath run for each edge of source vertex; void countPath(int s,int d){ int count=0; for (int i = 0; i < V;i++){ if(visited[i]==0&&adj_mat[s][i]==1){ cout << s << " "; searchForNode(i, d, &count); } } cout << count << ..

An alien spaceship is attacking on earth.The aliens want to destroy most of the civilization and make remaining ones their slave.They know all the major cities. Your task as a slave to find path for the spaceship to destroy all the cities and kill your brethren. You know distance of some cities from your current .. I have a DAG graph which contains two types of nodes, A and B. I am looking for a graph partitioning algorithm that can partition a graph in sub-graphs such that each sub-graph contains up to X number of node type B. For example, given this graph, I need to partition it topologically such that ..

I’m implementing an algorithm in C++ with Boost Graph. I want to find all the vertex in the neighborhood of v (so, all its neighbors), then change a property of their and finally clear all of their edges. I found in Boost the function adjacent_vertices(v,g) (where v is the vertex and g is the graph) ..

I have to find the vertex, whose paths to other paths (after summing) are the shortest. I know I can find the shortest path to all from one vertex by using Bellman-Ford algorithm, but I do not know how I can find optimal vertex, whose paths can be the shortest. Source: Windows Que..