0% found this document useful (0 votes)
286 views

ACSL GraphTheory

Graph theory is the study of graphs, which are mathematical structures used to model pairwise connections between objects. A graph consists of vertices and edges that connect pairs of vertices. Graphs can be used to represent many real-world networks. Key concepts in graph theory include paths, cycles, connected components, trees, and directed graphs. Graphs are commonly represented using adjacency matrices that encode which pairs of vertices have edges between them.

Uploaded by

PKDianna
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
286 views

ACSL GraphTheory

Graph theory is the study of graphs, which are mathematical structures used to model pairwise connections between objects. A graph consists of vertices and edges that connect pairs of vertices. Graphs can be used to represent many real-world networks. Key concepts in graph theory include paths, cycles, connected components, trees, and directed graphs. Graphs are commonly represented using adjacency matrices that encode which pairs of vertices have edges between them.

Uploaded by

PKDianna
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

GraphTheory

ThisdescriptionisadaptedfromRobertSedgewicksAlgorithms,(AddisonWesley,1983).This
book, a reference for virtually all genres of computer algorithms, contains many example
programsinPascal.Moreover,itislucidandwellwritten.Werecommendthisbookhighly.
Manyproblemsarenaturallyformulatedintermsofpointsandconnectionsbetweenthem.For
example,anelectriccircuithasgatesconnectedbywires,anairlinemaphascitiesconnectedby
routes,andaprogramflowcharthasboxesconnectedbyarrows. Agraphisamathematical
objectwhichmodelssuchsituations.
Agraphisacollectionofverticesandedges.Anedgeisaconnectionbetweentwovertices(or
nodes).Onecandrawagraphbymarkingpointsfortheverticesanddrawinglinesconnecting
themfortheedges,butitmustbeborneinmindthatthegraphisdefinedindependentlyofthe
representation.Forexample,thefollowingtwodrawingsrepresentthesamegraph:(page374)
I

K
M

D
D
E

E
F

Theprecisewaytorepresentthisgraphistosaythatitconsistsofthesetofvertices{A,B,C,D,
E,F,G,H,I,J,K,L,M},andthesetofedgesbetweenthesevertices{AG,AB,AC,LM,JM,JL,
JK,ED,FD,HI,FE,AF,GE}.
A path from vertex x to y inagraph is alist ofvertices, inwhichsuccessive vertices are
connectedbyedgesinthegraph.Forexample,BAFEGispathfromBtoGinthegraphabove.
Asimplepathisapathwithnovertexrepeated.Forexample,BAFEGACisnotasimplepath.
Agraphis connected ifthereisapathfromeveryvertextoeveryothervertexinthegraph.
Intuitively,iftheverticeswerephysicalobjectsandtheedgeswerestringsconnectingthem,a
connectedgraphwouldstayinonepieceifpickedupbyanyvertex. Agraphwhichisnot
connected is made up of connected components. For example, the graph above has three
connectedcomponents:{I,H},{J,K,L,M}and{A,B,C,D,E,F,G}.
Acycleisapath,whichissimpleexceptthatthefirstandlastvertexarethesame(apathfroma
pointbacktoitself).Forexample,thepathAFEGAisacycleinourexample.Verticesmustbe
listedintheorderthattheyaretraveledtomakethepath;anyoftheverticesmaybelistedfirst.
Thus,FEGAFandGAFEGaredifferentwaystoidentifythesamecycle.Forclarity,welistthe
start/endvertextwice:onceatthestartofthecycleandonceattheend.Agraphwithnocycles
iscalledatree.Thereisonlyonepathbetweenanytwonodesinatree.AtreeonNvertices
contains exactly N1edges. A spanningtree ofagraphisasubgraphthatcontains allthe
verticesandformsatree.Agroupofdisconnectedtreesiscalledaforest.

1of3

GraphTheory

Directedgraphsaregraphswhichhaveadirectionassociatedwitheachedge.Anedgexyina
directedgraphcanbeusedinapaththatgoesfromxtoybutnotnecessarilyfromytox.For
example,adirectedgraphsimilartoourexamplegraphisdrawnbelow.(page422)
H

A
C
B
D

G
E

ThereisonlyonedirectedpathfromDtoF.NotethattherearetwoedgesbetweenHandI,one
eachdirection,whichessentiallymakesanundirectededge.Anundirectedgraphcanbethought
ofasadirectedgraphwithalledgesoccurringinpairsinthisway.Adag(directedacyclic
graph)isadirectedgraphwithnocycles.
WelldenotethenumberofverticesinagivengraphbyV,thenumberofedgesbyE.Notethat
EcanrangeanywherefromVtoV2(or1/2V(V1)inanundirectedgraph).Graphswillalledges
presentarecalledcompletegraphs;graphswithrelativelyfewedgespresent(saylessthanV
log(V))arecalledsparse;graphswithrelativelyfewedgesmissingarecalleddense.
Itisfrequentlyconvenienttorepresentagraphbyamatrix,asshowninthesecondsample
problembelow.IfweconsidervertexAas1,Bas2,etc.,thenaoneinMatrowiandcolumn
jindicatesthatthereisapathfromvertexitoj.IfweraiseMtothepthpower,theresulting
matrixindicateswhichpathsoflengthpexistinthegraph.Infact,thequantityMp(i,j)isthe
numberofpaths.
References
Ore,Oystein.GraphsandTheirUses,MAANewMathematicLibrary#10(1963).
Sedgewick,Robert.Algorithms.AddisonWesley(1983).

2of3

GraphTheory
SampleProblems
Findthenumberofdifferentcycles
containedinthedirectedgraphwith
vertices
{A,B,C,D,E}
andedges
{AB,BA,BC,CD,DC,DB,DE}.

Thegraphisasfollows:
A

Byinspection,thecyclesare:{A,B},{B,C,D}and
{C,D}.Thus,thereare3cyclesinthegraph.
Inthefollowingdirectedgraph,findthe Byinspection,theonlypathoflength2is
totalnumberofdifferentpathsfrom
AAC.
vertexAtovertexCoflength2or4.
Thepathsoflength4are:AAAAC,
AACACandACAAC.
A

Alternatively,letmatrixMrepresentthegraph.
Recallthatthenumberofpathsfromvertexito
vertexjoflengthpequalsMp(i,j).Thevaluesof
M,M2andM4are:
101201503
011,111,413
100101302

Thereis1pathoflength2(M2(1,3))and3pathsof
length4(M4(1,3)).

3of3

You might also like