Topological Sort: Finding a Contradiction

In summary, the topological sort of a graph is an order of its nodes along a horizontal line where all directed edges go from left to right. This can be shown by finding a linear order on the vertices such that the existence of an edge from one vertex to another implies the first vertex comes before the second. The discovery and finishing times of nodes can be found using the DFS algorithm.
  • #1
evinda
Gold Member
MHB
3,836
0
Hello! (Wave)

The topological sort of a graph can be considered as an order of its nodes along a horizontal line so that all the directed edges go from the left to the right.

How could we show that all the directed edges go fom the left to the right?

We suppose that it is:

View attachment 3843

Then it holds that $[d(w),f(w)] \subset [d(u),f(u)]$, right? (Thinking)

How could we find a contradiction?
 

Attachments

  • graph4.png
    graph4.png
    1.5 KB · Views: 66
Technology news on Phys.org
  • #2
There is a distinction between a graph and its embedding in the plane. One cannot ask whether this vertex lies to the left of that vertex when talking about a graph, but this is a legitimate question about an embedding. The definition of the topological sort refers to a particular embedding of the given graph where all vertices lie on a line. It is possible to give an equivalent definition that does not refer to embeddings: simply require that there is a linear order $<$ on vertices such that the existence of an edge from $u$ to $v$ implies $u<v$.

evinda said:
Then it holds that $[d(w),f(w)] \subset [d(u),f(u)]$, right?
Could you explain the notation used in this formula?
 
  • #3
Evgeny.Makarov said:
Could you explain the notation used in this formula?
[m] d(u) [/m] is the discovery time of the node [m] u [/m], the first time we visit it.
[m] f(u) [/m] is the finishing time of the node [m] u [/m], the time when it can be considered discovered.

We find these values using the [m] DFS [/m] algorithm.

This the algorithm that it given for the topological sort:
Code:
TOPOLOGICALSORT(G)
1. Call DFS(G) to compute finishing times f(v),  for all v in V.
2. When a vertex is finished put it in front of a linked list.
3. return the linked list of vertices.
 

FAQ: Topological Sort: Finding a Contradiction

What is topological sort and why is it important?

Topological sort is a graph algorithm used to find a linear ordering of vertices in a directed acyclic graph (DAG). It is important because it helps in identifying dependencies between tasks and can be used to schedule tasks in an efficient manner.

How does topological sort work?

Topological sort works by first identifying vertices with no incoming edges, which are called "sources." These sources are added to the sorted list. Then, their outgoing edges are removed, and the process is repeated until all vertices have been added to the sorted list. If there are still vertices with incoming edges after all sources have been added, then the graph contains a cycle and a topological sort cannot be performed.

What is a contradiction in topological sort?

A contradiction in topological sort occurs when a graph contains a cycle. This means that there is a circular dependency between tasks, making it impossible to determine a linear ordering of the tasks.

How can you find a contradiction in topological sort?

To find a contradiction in topological sort, you can use a depth-first search (DFS) or breadth-first search (BFS) algorithm. These algorithms traverse the graph and check for back edges, which indicate the presence of a cycle. If a back edge is found, then a contradiction exists in the graph.

Can topological sort be used on graphs with cycles?

No, topological sort cannot be used on graphs with cycles. As mentioned earlier, a contradiction occurs when a cycle is present in the graph, and a topological sort cannot be performed in this case. To use topological sort, the graph must be a directed acyclic graph (DAG).

Similar threads

Replies
15
Views
1K
Replies
46
Views
7K
Replies
1
Views
452
Replies
7
Views
3K
Replies
11
Views
3K
Back
Top