Skip to content

update old links #276

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

Merged
merged 3 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ e-maxx-eng

Translation of http://e-maxx.ru into English

Compiled pages are published at http://e-maxx-eng.appspot.com/
Compiled pages are published at https://cp-algorithms.com/

Manual for contributors: http://e-maxx-eng.appspot.com/contrib.html
Manual for contributors: https://cp-algorithms.com/contrib.html

Test-your-page form: http://e-maxx-eng.appspot.com/test.php
Test-your-page form: https://cp-algorithms.com/test.php
2 changes: 1 addition & 1 deletion src/combinatorics/generating_combinations.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool next_combination(vector<int>& a, int n) {
This time we want to generate all $K$-combinations in such
an order, that adjacent combinations differ exactly by one element.

This can be solved using the [Gray Code](https://e-maxx-eng.appspot.com/algebra/gray-code.html):
This can be solved using the [Gray Code](./algebra/gray-code.html):
If we assign a bitmask to each subset, then by generating and iterating over these bitmasks with Gray codes, we can obtain our answer.

The task of generating $K$-combinations can also be solved using Gray Codes in a different way:
Expand Down
2 changes: 1 addition & 1 deletion src/contrib.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

We collaborate via means of github.

Generated pages are compiled and published at [http://e-maxx-eng.appspot.com](http://e-maxx-eng.appspot.com).
Generated pages are compiled and published at [https://cp-algorithms.com](https://cp-algorithms.com).

And sources (to which you may want to contribute) are [here](http://github.com/e-maxx-eng/e-maxx-eng/tree/master/src).

Expand Down
10 changes: 5 additions & 5 deletions src/graph/strongly-connected-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You are given a directed graph $G$ with vertices $V$ and edges $E$. It is possib
$$
u \mapsto v, v \mapsto u
$$
where $\mapsto$ means reachability, i.e. existance of the path from first vertex to the second.
where $\mapsto$ means reachability, i.e. existence of the path from first vertex to the second.

It is obvious, that strongly connected components do not intersect each other, i.e. this is a partition of all graph vertices. Thus we can give a definition of condensation graph $G^{SCC}$ as a graph containing every strongly connected component as one vertex. Each vertex of the condensation graph corresponds to the strongly connected component of graph $G$. There is an oriented edge between two vertices $C_i$ and $C_j$ of the condensation graph if and only if there are two vertices $u \in C_i, v \in C_j$ such that there is an edge in initial graph, i.e. $(u, v) \in E$.

Expand All @@ -18,7 +18,7 @@ The most important property of the condensation graph is that it is **acyclic**.
The algorithm described in the next section extracts all strongly connected components in a given graph. It is quite easy to build a condensation graph then.

## Description of the algorithm
Described algorithm was independently suggested by Kosaraju and Sharir at 1979. This is an easy-to-implement algorithm based on two series of [depth first search](http://e-maxx-eng.appspot.com/graph/depth-first-search.html), and working for $O(n + m)$ time.
Described algorithm was independently suggested by Kosaraju and Sharir at 1979. This is an easy-to-implement algorithm based on two series of [depth first search](./graph/depth-first-search.html), and working for $O(n + m)$ time.

**On the first step** of the algorithm we are doing sequence of depth first searches, visiting the entire graph. We start at each vertex of the graph and run a depth first search from every non-visited vertex. For each vertex we are keeping track of **exit time** $tout[v]$. These exit times have a key role in an algorithm and this role is expressed in next theorem.

Expand All @@ -28,7 +28,7 @@ First, let's make notations: let's define exit time $tout[C]$ from the strongly

There are two main different cases at the proof depending on which component will be visited by depth first search first, i.e. depending on difference between $tin[C]$ and $tin[C']$:
** The component $C$ was reached first. It means that depth first search comes at some vertex $v$ of component $C$ at some moment, but all other vertices of components $C$ and $C'$ were not visited yet. By condition there is an edge $(C, C')$ in a condensation graph, so not only the entire component $C$ is reachable from $v$ but the whole component $C'$ is reachable as well. It means that depth first search that is running from vertex $v$ will visit all vertices of components $C$ and $C'$, so they will be descendants for $v$ in a depth first search tree, i.e. for each vertex $u \in C \cup C', u \ne v$ we have that $tout[v] > tout[u]$, as we claimed.
** Assume that component $C'$ was visited first. Similarly, depth first search comes at some vertex $v$ of component $C'$ at some moment, but all other vertices of components $C$ and $C'$ were not visited yet. But by condition there is an edge $(C, C')$ in the condensation graph, so, because of acyclic propery of condensation graph, there is no back path from $C'$ to $C$, i.e. depth first search from vertex $v$ will not reach vertices of $C$. It means that vertices of $C$ will be visited by depth first search later, so $tout[C] > tout[C']$. This completes the proof.
** Assume that component $C'$ was visited first. Similarly, depth first search comes at some vertex $v$ of component $C'$ at some moment, but all other vertices of components $C$ and $C'$ were not visited yet. But by condition there is an edge $(C, C')$ in the condensation graph, so, because of acyclic property of condensation graph, there is no back path from $C'$ to $C$, i.e. depth first search from vertex $v$ will not reach vertices of $C$. It means that vertices of $C$ will be visited by depth first search later, so $tout[C] > tout[C']$. This completes the proof.

Proved theorem is **the base of algorithm** for finding strongly connected components. It follows that any edge $(C, C')$ in condensation graph comes from a component with a larger value of $tout$ to component with a smaller value.

Expand All @@ -44,9 +44,9 @@ Thus, we built next **algorithm** for selecting strongly connected components:

2nd step. Build transposed graph $G^T$. Run a series of depth (breadth) first searches in the order determined by list $order$ (to be exact in reverse order, i.e. in decreasing order of exit times). Every set of vertices, reached after the next search, will be the next strongly connected component.

Algorithm asymptotics is $O(n + m)$, because it is just two depth (breadth) first searches.
Algorithm asymptotic is $O(n + m)$, because it is just two depth (breadth) first searches.

Finally, it is appropriate to mention [topological sort](http://e-maxx-eng.appspot.com/graph/topological-sort.html) here. First of all, step 1 of the algorithm represents topological sort of graph $G$ (actually this is exactly what vertices' sort by exit time means). Secondly, the algorithm's scheme generates strongly connected components by decreasing order of their exit times, thus it generates components - vertices of condensation graph - in topological sort order.
Finally, it is appropriate to mention [topological sort](./graph/topological-sort.html) here. First of all, step 1 of the algorithm represents topological sort of graph $G$ (actually this is exactly what vertices' sort by exit time means). Secondly, the algorithm's scheme generates strongly connected components by decreasing order of their exit times, thus it generates components - vertices of condensation graph - in topological sort order.

## Implementation
```cpp
Expand Down