Skip to content

Commit 9415555

Browse files
authored
Merge pull request #56 from Debashis08/release
Release
2 parents 5b10651 + 84a5c35 commit 9415555

16 files changed

+624
-53
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,28 @@
1-
---
2-
name: Bug report
3-
about: Create a report to help us improve
4-
title: ''
5-
labels: ''
6-
assignees: ''
1+
## Bug Report
72

8-
---
3+
### Describe the Bug
4+
_A clear and concise description of what the bug is._
95

10-
**Describe the bug**
11-
A clear and concise description of what the bug is.
6+
### Steps to Reproduce
7+
_Steps to reproduce the behavior:_
8+
1. Go to `path/to/file.cpp`
9+
2. Run the test case: `./test_case_name`
10+
3. Observe the error
1211

13-
**To Reproduce**
14-
Steps to reproduce the behavior:
15-
1. Go to '...'
16-
2. Click on '....'
17-
3. Scroll down to '....'
18-
4. See error
12+
### Expected Behavior
13+
_A clear and concise description of what you expected to happen._
1914

20-
**Expected behavior**
21-
A clear and concise description of what you expected to happen.
15+
### Screenshots/Outputs
16+
_If applicable, add screenshots or log output to help explain the issue._
2217

23-
**Screenshots**
24-
If applicable, add screenshots to help explain your problem.
18+
### Environment (please complete the following information):
19+
- **OS:** [e.g., Windows, macOS, Linux]
20+
- **Compiler:** [e.g., GCC 11, Clang 14, MSVC]
21+
- **CMake Version:** [if applicable]
22+
- **Any other relevant setup details**
2523

26-
**Desktop (please complete the following information):**
27-
- OS: [e.g. iOS]
28-
- Browser [e.g. chrome, safari]
29-
- Version [e.g. 22]
24+
### Possible Fix (Optional)
25+
_If you have an idea of how to fix it, mention it here._
3026

31-
**Smartphone (please complete the following information):**
32-
- Device: [e.g. iPhone6]
33-
- OS: [e.g. iOS8.1]
34-
- Browser [e.g. stock browser, safari]
35-
- Version [e.g. 22]
36-
37-
**Additional context**
38-
Add any other context about the problem here.
27+
### Additional Context
28+
_Add any other context about the problem here._

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
# Pull Request Template
1+
### Description
22

3-
## Description
43

54

6-
7-
## Type of Change
5+
### Type of Change
86

97
- [ ] Bug fix
108
- [ ] New feature
@@ -13,5 +11,5 @@
1311
- [ ] Documentation update
1412

1513

16-
## Additional Notes
14+
### Additional Notes
1715

CODE_OF_CONDUCT.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Contributor Covenant Code of Conduct
1+
## Contributor Covenant Code of Conduct
22

3-
## Our Pledge
3+
### Our Pledge
44

55
We as members, contributors, and leaders pledge to make participation in our
66
community a harassment-free experience for everyone, regardless of age, body
@@ -12,7 +12,7 @@ and orientation.
1212
We pledge to act and interact in ways that contribute to an open, welcoming,
1313
diverse, inclusive, and healthy community.
1414

15-
## Our Standards
15+
### Our Standards
1616

1717
Examples of behavior that contributes to a positive environment for our
1818
community include:
@@ -36,7 +36,7 @@ Examples of unacceptable behavior include:
3636
* Other conduct which could reasonably be considered inappropriate in a
3737
professional setting
3838

39-
## Enforcement Responsibilities
39+
### Enforcement Responsibilities
4040

4141
Community leaders are responsible for clarifying and enforcing our standards of
4242
acceptable behavior and will take appropriate and fair corrective action in
@@ -48,30 +48,29 @@ comments, commits, code, wiki edits, issues, and other contributions that are
4848
not aligned to this Code of Conduct, and will communicate reasons for moderation
4949
decisions when appropriate.
5050

51-
## Scope
51+
### Scope
5252

5353
This Code of Conduct applies within all community spaces, and also applies when
5454
an individual is officially representing the community in public spaces.
5555
Examples of representing our community include using an official e-mail address,
5656
posting via an official social media account, or acting as an appointed
5757
representative at an online or offline event.
5858

59-
## Enforcement
59+
### Enforcement
6060

6161
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62-
reported to the community leaders responsible for enforcement at
63-
.
62+
reported to the community leaders responsible for enforcement at.
6463
All complaints will be reviewed and investigated promptly and fairly.
6564

6665
All community leaders are obligated to respect the privacy and security of the
6766
reporter of any incident.
6867

69-
## Enforcement Guidelines
68+
### Enforcement Guidelines
7069

7170
Community leaders will follow these Community Impact Guidelines in determining
7271
the consequences for any action they deem in violation of this Code of Conduct:
7372

74-
### 1. Correction
73+
#### 1. Correction
7574

7675
**Community Impact**: Use of inappropriate language or other behavior deemed
7776
unprofessional or unwelcome in the community.
@@ -80,7 +79,7 @@ unprofessional or unwelcome in the community.
8079
clarity around the nature of the violation and an explanation of why the
8180
behavior was inappropriate. A public apology may be requested.
8281

83-
### 2. Warning
82+
#### 2. Warning
8483

8584
**Community Impact**: A violation through a single incident or series
8685
of actions.
@@ -92,7 +91,7 @@ includes avoiding interactions in community spaces as well as external channels
9291
like social media. Violating these terms may lead to a temporary or
9392
permanent ban.
9493

95-
### 3. Temporary Ban
94+
#### 3. Temporary Ban
9695

9796
**Community Impact**: A serious violation of community standards, including
9897
sustained inappropriate behavior.
@@ -103,7 +102,7 @@ private interaction with the people involved, including unsolicited interaction
103102
with those enforcing the Code of Conduct, is allowed during this period.
104103
Violating these terms may lead to a permanent ban.
105104

106-
### 4. Permanent Ban
105+
#### 4. Permanent Ban
107106

108107
**Community Impact**: Demonstrating a pattern of violation of community
109108
standards, including sustained inappropriate behavior, harassment of an
@@ -112,7 +111,7 @@ individual, or aggression toward or disparagement of classes of individuals.
112111
**Consequence**: A permanent ban from any sort of public interaction within
113112
the community.
114113

115-
## Attribution
114+
### Attribution
116115

117116
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118117
version 2.0, available at

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
### This project is for academic purpose, no contributions are expected right now.
1+
## This project is for academic purpose, no contributions are expected right now.

Headers/0003_Graph/0003_TopologicalSort.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace TopologicalSort
1717
int color;
1818
int discoveryTime;
1919
int finishingTime;
20+
int inDegree;
2021
Node* parent;
2122
Node(int value);
2223
};
@@ -35,6 +36,7 @@ namespace TopologicalSort
3536
void PushDirectedEdge(int valueU, int valueV);
3637
void PushSingleNode(int valueU);
3738
void TopologicalSort();
39+
void KahnTopologicalSort();
3840
vector<pair<int, pair<int, int>>> ShowTopologicalSortResult();
3941
};
4042
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#pragma once
2+
3+
#include<vector>
4+
using namespace std;
5+
6+
namespace AllPairsShortestPathsFloydWarshall
7+
{
8+
class Graph
9+
{
10+
private:
11+
int _noOfVertices;
12+
vector<vector<int>> _adjMatrix;
13+
vector<vector<int>> _shortestPathMatrixFloydWarshall;
14+
vector<vector<int>> _predecessorMatrix;
15+
void InitializeDistanceAndPredecessors();
16+
void GetShortestPath(int source, int destination, vector<int>& path);
17+
18+
public:
19+
void CreateGraph(int noOfVertices);
20+
void PushDirectedEdge(int valueU, int valueV, int weight);
21+
void FindAllPairsShortestPathsFloydWarshallSolution();
22+
vector<vector<int>> GetFloydWarshallShortestPath();
23+
};
24+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#pragma once
2+
3+
#include<map>
4+
#include<vector>
5+
#include<set>
6+
using namespace std;
7+
8+
namespace AllPairsShortestPathsJohnson
9+
{
10+
class Node
11+
{
12+
public:
13+
int data;
14+
int distance;
15+
Node* parent;
16+
int potentialWeight;
17+
Node(int data);
18+
};
19+
20+
class Edge
21+
{
22+
public:
23+
Node* nodeU;
24+
Node* nodeV;
25+
int weight;
26+
Edge(Node* nodeU, Node* nodeV, int weight);
27+
};
28+
29+
class CompareNodeDistance
30+
{
31+
public:
32+
bool operator()(const Node* nodeU, const Node* nodeV) const
33+
{
34+
return nodeU->distance < nodeV->distance;
35+
}
36+
};
37+
38+
class Graph
39+
{
40+
private:
41+
int _noOfVertices=0;
42+
map<Node*, vector<Node*>> _adjlist;
43+
map<int, Node*> _nodeMap;
44+
vector<Edge*> _edgeList;
45+
map<Node*, vector<Edge*>> _edgeMap;
46+
map<Node*, vector<Node*>> _augmentedAdjlist;
47+
vector<Edge*> _augmentedEdgeList;
48+
multiset<Node*, CompareNodeDistance> _operationalSet;
49+
vector<vector<int>> _shortestPathMatrix;
50+
vector<vector<int>> _predecessorMatrix;
51+
Node* MakeOrFindNode(int data);
52+
void PushAugmentedDirectedEdges(Node* sourceNode, Node* nodeV, int weight);
53+
void InitializeSingleSource(Node* sourceNode);
54+
void RelaxBellmanFord(Edge* edge);
55+
bool BellmanFord(Node* source);
56+
void RelaxDijkstra(Edge* edge);
57+
void Dijkstra(Node* source);
58+
void GetShortestPath(int source, int destination, vector<int>& path);
59+
60+
public:
61+
void PushDirectedEdge(int dataU, int dataV, int weight);
62+
bool FindAllPairsShortestPathsJohnsonAlgorithm();
63+
vector<vector<int>> GetAllPairsShortestPathsDistanceMatrix();
64+
vector<vector<int>> GetAllPairsShortestPathsPathMatrix();
65+
};
66+
}

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Security Policy
1+
## Security Policy

SourceCodes/0003_Graph/0003_TopologicalSort.cc

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "../Headers/0003_Graph/0003_TopologicalSort.h"
22
#include<vector>
3+
#include<queue>
34
#include<utility>
45
#include<climits>
56
#include<stdexcept>
@@ -10,9 +11,10 @@ namespace TopologicalSort
1011
Node::Node(int value)
1112
{
1213
this->data = value;
14+
this->color = WHITE;
1315
this->discoveryTime = INT_MAX;
1416
this->finishingTime = INT_MAX;
15-
this->color = WHITE;
17+
this->inDegree = 0;
1618
this->parent = nullptr;
1719
}
1820

@@ -61,6 +63,7 @@ namespace TopologicalSort
6163
Node* nodeV = this->MakeOrFindNode(valueV);
6264

6365
this->_adjlist[nodeU].push_back(nodeV);
66+
nodeV->inDegree++;
6467
}
6568

6669
void Graph::PushSingleNode(int valueU)
@@ -84,6 +87,53 @@ namespace TopologicalSort
8487
}
8588
}
8689

90+
void Graph::KahnTopologicalSort()
91+
{
92+
// Step-1 Compute in-degree of each vertices
93+
// This is already done while creating the graph
94+
this->time = 0;
95+
queue<Node*> nodeQueue;
96+
97+
// Step-2 Enqueue vertices with in-degree 0
98+
for (auto& node : this->_nodeMap)
99+
{
100+
if (node.second->inDegree == 0)
101+
{
102+
this->time++;
103+
node.second->discoveryTime = time;
104+
nodeQueue.push(node.second);
105+
}
106+
}
107+
108+
// Step-3 Process vertices in queue
109+
while (!nodeQueue.empty())
110+
{
111+
Node* node = nodeQueue.front();
112+
nodeQueue.pop();
113+
this->time++;
114+
node->finishingTime = time;
115+
this->_topologicalSortedNodeList.push_back(node);
116+
117+
// Step-4 Process all the neighbours of current node based on in-degree
118+
for (auto& neighbour : this->_adjlist[node])
119+
{
120+
neighbour->inDegree--;
121+
if (neighbour->inDegree == 0)
122+
{
123+
this->time++;
124+
neighbour->discoveryTime = time;
125+
nodeQueue.push(neighbour);
126+
}
127+
}
128+
}
129+
130+
// Step-5 Check if a cycle exists
131+
if (this->_topologicalSortedNodeList.size() != this->_nodeMap.size())
132+
{
133+
this->hasCycle = true;
134+
}
135+
}
136+
87137
vector<pair<int, pair<int, int>>> Graph::ShowTopologicalSortResult()
88138
{
89139
if (this->hasCycle == true)

0 commit comments

Comments
 (0)