-
-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bridge Trees #1781
Bridge Trees #1781
Conversation
Thank you for submitting your pull request! 🙌 We'll review it as soon as possible.). If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊 |
⚡️ Lighthouse Report for the Deploy Preview of this PR 🚀
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please carefully read our contribution guidelines. They provide information on our documentation format and syntax.
I noticed that the PR validation check is failing, while other checks have passed successfully. I will review the logs for the failing check to address any issues. If there are specific concerns or feedback on the implementation, I’d appreciate your insights! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My comment concerns the format of your code in the .md
file for our docs. Please follow our format for best practices.
what changes you requested @ajay-dhangar |
We need only markdown files, so please write your code in markdown language and save your file with a .md extension. Also, please follow our format and syntax. |
Bridge Tree ConstructionIntroductionA bridge in a graph is an edge that, if removed, would disconnect the graph. A bridge tree is a graph where each node represents a component of the original graph that does not contain any bridges, and the edges of the bridge tree represent the bridges of the original graph. Properties of the Bridge Tree
Time Complexity
Thus, the total time complexity for constructing the bridge tree is O(N + M). Pseudocode for Constructing the Bridge TreeDFS Functionvoid dfs(int node, int component_number) {
component[node] = component_number; // Mark the component number for the node
vis[node] = true; // Mark the node as visited
for each adjacent edge where the edge is not a bridge {
int next = other endpoint of the edge;
if (vis[next] == true) {
continue; // Skip if already visited
}
dfs(next, component_number); // Recursively explore
}
}
void main() {
// Step 1: Find all the bridges in the graph
find_bridges(); // This function is assumed to find all the bridges (refer to prerequisites for this)
// Step 2: For each node, call DFS to identify components
for (int i = 1; i <= n; ++i) {
if (vis[i] == false) {
dfs(i, unique_component_number); // Call DFS for unvisited nodes, with a unique component number
unique_component_number++; // Increment the component number for each DFS call
}
}
} |
adding Bridge trees algo