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: 47
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.
 

1. 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.

2. 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.

3. 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.

4. 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.

5. 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

  • Calculus and Beyond Homework Help
2
Replies
58
Views
3K
  • Programming and Computer Science
Replies
15
Views
1K
Replies
1
Views
1K
  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
2
Replies
46
Views
7K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Topology and Analysis
Replies
8
Views
2K
  • Programming and Computer Science
Replies
7
Views
2K
  • Calculus and Beyond Homework Help
Replies
20
Views
2K
  • Programming and Computer Science
Replies
11
Views
3K
Back
Top