mirror of
https://github.com/guilhermewerner/paa
synced 2025-06-15 21:14:18 +00:00
Clone graphs code
This commit is contained in:
44
Source/Graph.h
Normal file
44
Source/Graph.h
Normal file
@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <bits/stdc++.h>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <sstream>
|
||||
#include <string.h>
|
||||
#include <thread>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Graph
|
||||
{
|
||||
private:
|
||||
int length;
|
||||
list<int> *adj;
|
||||
|
||||
public:
|
||||
Graph(int length)
|
||||
{
|
||||
this->length = length;
|
||||
this->adj = new list<int>[length];
|
||||
}
|
||||
|
||||
~Graph()
|
||||
{
|
||||
delete[] adj;
|
||||
}
|
||||
|
||||
public:
|
||||
void Print();
|
||||
void Insert(int u, int v);
|
||||
void InsertD(int u, int v);
|
||||
void Remove(int u, int v);
|
||||
void RemoveD(int u, int v);
|
||||
Graph *Clone();
|
||||
|
||||
private:
|
||||
void DFS(int u, vector<int> &disc, vector<int> &low, vector<int> &parent, vector<pair<int, int>> &bridge);
|
||||
int DFSCount(int v, bool visited[]);
|
||||
};
|
Reference in New Issue
Block a user