Editing Graph theory

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
A '''graph''' is a mathematical object with '''vertices''' (also known as '''nodes'''), discrete objects, and '''edges''' (also known as '''arcs'''), relationships between pairs of objects. Because of the wide variety of objects and relationships that may be abstracted as vertices and edges, graphs are highly versatile, and may be used to model a great number of different real-world entities, such as cities and highways, social networks, and the positions of the Rubik's Cube. Likewise, many interesting problems in computer science concern graphs themselves. The subdiscipline of mathematics and computer science concerning graphs is known as ''graph theory''.
+
A '''graph''' is a mathematical object with '''vertices''' (also known as '''nodes'''), discrete objects, and '''edges''', relationships between pairs of objects. Because of the wide variety of objects and relationships that may be abstracted as vertices and edges, graphs are highly versatile, and may be used to model a great number of different real-world entities, such as cities and highways, social networks, and the positions of the Rubik's Cube. Likewise, many interesting problems in computer science concern graphs themselves. The subdiscipline of mathematics and computer science concerning graphs is known as ''graph theory''.
  
 
==Structure of a graph==
 
==Structure of a graph==
Line 10: Line 10:
  
 
===Directed and undirected graphs===
 
===Directed and undirected graphs===
Some relationships are two-way, but some are only one-way. For example, suppose that in the social network example given in the preceding section, we place an edge between the vertices representing two people if and only if one of them has a crush on the other. The trouble here is that clearly, Alice having a crush on Bob is different than Bob having a crush on Alice, and hence these two scenarios ought to be represented by ''different graphs''. In order to arrange this, we stipulate that each edge also has a ''direction'', and that an edge from <math>u</math> to <math>v</math> is not the same as an edge from <math>v</math> to <math>u</math>. A graph that encodes this one-way information is known as a '''directed graph''' or '''digraph''', whereas one that does not is an '''undirected graph'''. When an edge from <math>u</math> to <math>v</math> is drawn in the diagram of a graph, generally an arrowhead is added on the end of the line segment representing that edge near <math>v</math>, so that the segment "points" from <math>u</math> to <math>v</math>. Note that it is possible for two-way relationships to be represented by directed graphs; maybe Alice and Bob secretly have a crush on each other. This would be represented by both edges existing in <math>E</math> and a double-ended arrow. The point is that directed graphs must be used when it is not guaranteed that all relationships will be bidirectional. An edge from <math>u</math> to <math>v</math> is said to '''enter''' <math>v</math> and '''leave''' <math>u</math>. An edge in a directed graph is also known as an '''arc'''.
+
Some relationships are two-way, but some are only one-way. For example, suppose that in the social network example given in the preceding section, we place an edge between the vertices representing two people if and only if one of them has a crush on the other. The trouble here is that clearly, Alice having a crush on Bob is different than Bob having a crush on Alice, and hence these two scenarios ought to be represented by ''different graphs''. In order to arrange this, we stipulate that each edge also has a ''direction'', and that an edge from <math>u</math> to <math>v</math> is not the same as an edge from <math>v</math> to <math>u</math>. A graph that encodes this one-way information is known as a '''directed graph''', whereas one that does not is an '''undirected graph'''. When an edge from <math>u</math> to <math>v</math> is drawn in the diagram of a graph, generally an arrowhead is added on the end of the line segment representing that edge near <math>v</math>, so that the segment "points" from <math>u</math> to <math>v</math>. Note that it is possible for two-way relationships to be represented by directed graphs; maybe Alice and Bob secretly have a crush on each other. This would be represented by both edges existing in <math>E</math> and a double-ended arrow. The point is that directed graphs must be used when it is not guaranteed that all relationships will be bidirectional. An edge from <math>u</math> to <math>v</math> is said to '''enter''' <math>v</math> and '''leave''' <math>u</math>.
  
 
===Weighted graphs===
 
===Weighted graphs===
Line 51: Line 51:
  
 
===Types of graphs===
 
===Types of graphs===
A '''complete graph''' is one in which an edge exists between every pair of distinct vertices. If it is directed, it will have one each way. A complete directed graph on <math>n</math> vertices has <math>n(n-1)</math> edges (an edge from every vertex to every other). A complete undirected graph on <math>n</math> vertices, denoted <math>K_n</math>, will have half that many, <math>n(n-1)/2</math> edges.
 
 
 
Given a graph, if we remove some (possibly zero) vertices and some (possibly zero) edges, we obtain a '''subgraph'''. (Note that when a vertex is removed, all edges incident upon it must be removed too.)
 
Given a graph, if we remove some (possibly zero) vertices and some (possibly zero) edges, we obtain a '''subgraph'''. (Note that when a vertex is removed, all edges incident upon it must be removed too.)
  
An [[undirected graph]] is said to be '''connected''' if and only if every [[vertex]] is reachable from every other vertex. A [[directed graph]] is said to be '''strongly connected''' if and only if each pair of distinct vertices is mutually reachable. If an undirected graph is not connected, it has two or more [[subgraphs]] called '''connected components'''. A [[connected component]] consists of a vertex and all the vertices reachable from it (and all the incident edges); if two vertices are reachable from each other than they will be in the same connected component, but if not, they will be in different connected components. Put another way, define an [[equivalence relation]] on the vertices of the graph so that two vertices are equivalent if and only if one is reachable from the other; then connected components are equivalence classes. If a directed graph is not strongly connected, it has two or more subgraphs called '''strongly connected components'''; these are analogous to connected components, and two vertices are in the same [[strongly connected component]] if and only if they are mutually reachable. <span style="opacity:0">The definition for a strongly connected component in an [[undirected graph]] is uncommon will have to be clarified in a problem statement.</span>
+
An undirected graph is said to be '''connected''' if and only if every vertex is reachable from every other vertex. A directed graph is said to be '''strongly connected''' if and only if each pair of distinct vertices is mutually reachable. If an undirected graph is not connected, it has two or more subgraphs called '''connected components'''. A connected component consists of a vertex and all the vertices reachable from it (and all the incident edges); if two vertices are reachable from each other than they will be in the same connected component, but if not, they will be in different connected components. Put another way, define an equivalence relation on the vertices of the graph so that two vertices are equivalent if and only if one is reachable from the other; then connected components are equivalence classes. If a directed graph is not strongly connected, it has two or more subgraphs called '''strongly connected components'''; these are analogous to connected components, and two vertices are in the same strongly connected component if and only if they are mutually reachable.
  
 
A '''[[tree]]''' is an undirected graph that is both connected and acyclic. A '''forest''' is a graph that consists of one or more trees. If a graph is directed and acyclic, it is simply known as a '''[[directed acyclic graph]]''' or by the initialism '''DAG'''. A directed graph that is like a tree, but in which every edge points ''away'' from one of the tree's vertices, is called an '''arborescence'''.
 
A '''[[tree]]''' is an undirected graph that is both connected and acyclic. A '''forest''' is a graph that consists of one or more trees. If a graph is directed and acyclic, it is simply known as a '''[[directed acyclic graph]]''' or by the initialism '''DAG'''. A directed graph that is like a tree, but in which every edge points ''away'' from one of the tree's vertices, is called an '''arborescence'''.
Line 78: Line 76:
 
:* The '''bounded cost shortest path problem''' asks us to find the shortest path that does not exceed some fixed cost, where a cost is assigned to each edge in addition to its weight; this is like finding the shortest sequence of flights that fits within one's budget.
 
:* The '''bounded cost shortest path problem''' asks us to find the shortest path that does not exceed some fixed cost, where a cost is assigned to each edge in addition to its weight; this is like finding the shortest sequence of flights that fits within one's budget.
 
:* The problem of finding ''two'' paths between a given pair of vertices such that they have no common edges and the sum of their weights is minimized can be solved using [[Suurballe's algorithm]].
 
:* The problem of finding ''two'' paths between a given pair of vertices such that they have no common edges and the sum of their weights is minimized can be solved using [[Suurballe's algorithm]].
* '''Spanning tree''': A tree <math>T</math> is said to '''span''' a graph <math>G</math> when <math>T</math> is a subgraph of <math>G</math> and <math>T</math> contains all of <math>G</math>'s vertices. A spanning tree can be found in linear time using [[depth-first search]] or [[breadth-first search]].
+
* '''[[Minimum spanning tree]] problem''': The weight of a tree is the sum of the weights of the edges it contains. A tree <math>T</math> is said to '''span''' a graph <math>G</math> when <math>T</math> is a subgraph of <math>G</math> and <math>T</math> contains all of <math>G</math>'s vertices. Find a tree that spans <math>G</math>, while minimizing its weight.
:* '''[[Minimum spanning tree]] problem''': The weight of a tree is the sum of the weights of the edges it contains. Find a tree that spans <math>G</math>, while minimizing its weight. This can be accomplished using a priority-first search instead.
+
 
:* The '''[[minimum diameter spanning tree]] problem''' is analogous, but now we want a spanning tree with the lowest possible diameter.
 
:* The '''[[minimum diameter spanning tree]] problem''' is analogous, but now we want a spanning tree with the lowest possible diameter.
 
* The '''[[minimum spanning arborescence]] problem''' is analogous to the minimum spanning tree problem, but more difficult.
 
* The '''[[minimum spanning arborescence]] problem''' is analogous to the minimum spanning tree problem, but more difficult.
Line 88: Line 85:
 
:* '''Minimum vertex cut problem''': Find a subset of a flow graph's vertices, of minimum size, such that removing these vertices from the graph causes the sink to become unreachable from the source. (We are not allowed to remove the source or the sink.) This can be solved by replacing all nodes in the flow graph except the source and the sink by a pair of nodes, one for all the in-edges and one for all the out-edges, with an edge of cost 1 from the in-node to the out-node, and then finding a minimum edge cut, as above. (We set the costs of all other edges to infinity.)
 
:* '''Minimum vertex cut problem''': Find a subset of a flow graph's vertices, of minimum size, such that removing these vertices from the graph causes the sink to become unreachable from the source. (We are not allowed to remove the source or the sink.) This can be solved by replacing all nodes in the flow graph except the source and the sink by a pair of nodes, one for all the in-edges and one for all the out-edges, with an edge of cost 1 from the in-node to the out-node, and then finding a minimum edge cut, as above. (We set the costs of all other edges to infinity.)
 
:* '''[[Minimum cost maximum flow]] problem''': Maximize the flow, but also minimize the cost; the cost of sending flow along an edge is the product of the amount of flow along that edge and some constant specific to that edge.
 
:* '''[[Minimum cost maximum flow]] problem''': Maximize the flow, but also minimize the cost; the cost of sending flow along an edge is the product of the amount of flow along that edge and some constant specific to that edge.
* ''Finding strongly connected components'': Analogous to finding connected components, but in a directed graph. This is a bit trickier but can still be accomplished in linear time using [[Kosaraju's algorithm]], [[Tarjan's strongly connected components algorithm|Tarjan's algorithm]], or [[Gabow's algorithm]].
+
* ''Finding strongly connected components'': Analogous to finding connected components, but in a directed graph. This is a bit trickier but can still be accomplished in linear time using [[Kosaraju's algorithm]], [[Tarjan's algorithm]], or [[Gabow's algorithm]].
 
* ''Finding edge-connected and biconnected components'': We can identify all the cut vertices and cut edges of an undirected graph in linear time using [[Finding cut vertices and edges|a depth-first search algorithm due to Hopcroft and Tarjan]].
 
* ''Finding edge-connected and biconnected components'': We can identify all the cut vertices and cut edges of an undirected graph in linear time using [[Finding cut vertices and edges|a depth-first search algorithm due to Hopcroft and Tarjan]].
 
* ''Dominators'': These are like articulation points, but for directed graphs instead. In a control flow graph with source <math>s</math>, we say that a vertex <math>u</math> '''dominates''' a vertex <math>v</math> if every path from <math>s</math> to <math>v</math> must visit <math>u</math>. Every vertex dominates itself, but for all <math>v \neq s</math>, there is also an '''immediate dominator''' <math>u</math> such that <math>u \neq v</math>, <math>u</math> dominates <math>v</math>, and any other dominator of <math>v</math> that is not <math>v</math> itself also dominates <math>u</math>. Computing all immediate dominators gives a '''dominator tree''', which can be computed in linear time using the [[Lengauer–Tarjan algorithm]].
 
* ''Dominators'': These are like articulation points, but for directed graphs instead. In a control flow graph with source <math>s</math>, we say that a vertex <math>u</math> '''dominates''' a vertex <math>v</math> if every path from <math>s</math> to <math>v</math> must visit <math>u</math>. Every vertex dominates itself, but for all <math>v \neq s</math>, there is also an '''immediate dominator''' <math>u</math> such that <math>u \neq v</math>, <math>u</math> dominates <math>v</math>, and any other dominator of <math>v</math> that is not <math>v</math> itself also dominates <math>u</math>. Computing all immediate dominators gives a '''dominator tree''', which can be computed in linear time using the [[Lengauer–Tarjan algorithm]].
Line 96: Line 93:
 
* An '''independent set''' is a subset of a graph's vertices such that no two vertices in the subset are adjacent. The '''maximum independent subset problem''' is that of finding an independent subset of maximum size. This problem is NP-hard.
 
* An '''independent set''' is a subset of a graph's vertices such that no two vertices in the subset are adjacent. The '''maximum independent subset problem''' is that of finding an independent subset of maximum size. This problem is NP-hard.
 
* It is possible to determine whether a graph is planar in linear time using an algorithm due to Tarjan, but this is extremely complex.
 
* It is possible to determine whether a graph is planar in linear time using an algorithm due to Tarjan, but this is extremely complex.
 
[[Category:Graph theory]]
 
[[Category:Pages needing diagrams]]
 

Please note that all contributions to PEGWiki are considered to be released under the Attribution 3.0 Unported (see PEGWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)