I am trying to go through a txt file with facebook data from 2009 and represent people as vertices on a graph, and friendships as edges. The code to make the graph works perfectly. I used it to calculate the average number of friends that people in this data set had. But when trying to ..

#### Category : graph

Can somebody please help me in implementing DFS in an iterative fashion for graph traversal? I’m Getting segmentation fault. I suspect that error is in if statement where I have written check 4. I am not sure what happens when the adjacency list do not exist for that index. What condition should I write in ..

I am having problems while running my program. Basically, my program is about the directed and undirected graph. My classes are nodes, edges, graph (abstract), directed graph, undirected graph. I used an adjacency list to store my nodes: undirect graph class node class However, I am getting an uninitialized error when creating my objects: Also, ..

In a graph, a permutation of the vertices [v1, v2, …..vn] is called a lucky permutation if for every vertex vi (where 1 <= i <= N-1), there exists an edge between vi and vi+1. You are given a graph with N vertices and M bidirectional edges. Write a program to calculate the number of ..

I am currently doing a c++ coding course online and am stuck trying to figure out how to complete the question. I need to create a weighted undirected graph using nodes that have strings as references rather than int’s. I need to be able to find the amount of vertex’s, edges and be able to ..

Language: C++ IDE: Visual Studio 2019 I wrote a program that collects data on random graphs (different probabilities for edges) to prove a Erdős–Rényi model threshold. each graph has 1000 vertexes and i need to run 15,000 cases (5,000 of which are diameter – and that takes a while) so naturally i would want to ..

I trying to solve this problem : https://codeforces.com/contest/216/problem/B so I find I could use bipartite and coloring each node whether 0 or 1 and I implement this code #include <bits/stdc++.h> using namespace std; int n; int m; int cnt = 0; vector<int> graph[110]; bool visit[110]; bool cross[110]; bool color[110]; void dfs(int i, int c) { ..

beginner here, I was implementing an adjacency list to represent the graph in C++, I was stuck conceptually in the below code snippet. void addEdge(vector<int> adj[], int s, int d) { adj[s].push_back(d); adj[d].push_back(s); } vector<int> adj[] will contain list of all nodes My question is we have 1D vector adj[], how are we able to ..

In the boost graph library, there are two popular functions to read in graphs from a file: boost::read_graphviz(), and boost::read_graphml(), for the GraphViz and the GraphML format, respectively. Now both read generically to any type of boost::adjacency_list<…>, as they are derived from the Mutable Graph concept: #include <string> #include <fstream> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/adjacency_matrix.hpp> #include ..

I’m trying to find a vector of all the vertices, each of which is directly connected with the given vertex by an edge. I’m very certain that I have made quite a few errors as the compiler states the ones I have listed below. I’m relatively new to this and am not really sure of ..

## Recent Comments