7 views

Uploaded by MELJUN CORTES, MBA,MPA

MELJUN CORTES DATA STRUCTURES Graph

- ch10
- Albrecht Heeffer y Andreas M. Hinz - A difficult case. Pacioli and Cardano on the chinese rings
- Graph Theory Lecture
- ON BIPOLAR SINGLE VALUED NEUTROSOPHIC GRAPHS
- Graph Coloring in Parallel Processing and Scientific Computing
- Single-Valued Neutrosophic Graph Structures
- Unit v Graph_notes
- lab9
- DemokritosGR.proceedings
- 9783319405414-c2
- Graphs - DATA Structures
- 00857718
- SN_2014022715034583
- 633,Pretti,ConnectTheDots Presentation
- Certain Properties of Bipolar Neutrosophic Graphs
- R3_2
- math lesson plan
- Lecture 7 - Parser Evaluation, Lexicalized PCFG, Dependency Parsing Introduction - Evaluasi Parser Dan Dependency Parsing
- MCS 033 Notes
- CAA

You are on page 1of 17

Graphs

one of the most versatile structures used in

computer programming

have shape dictated by a physical problem

nodes are called vertices (the singular is vertex)

Graphs

* Property of STI

Page 1 of 17

Data Structures

Graphs

straight lines connecting the circles represent

freeways segments

the circles are the vertices and the lines are the

edges

Graphs

* Property of STI

Page 2 of 17

Data Structures

Graphs

Adjacency

if they are connected by a single edge

Neighbors

Path

a sequence of edges

Connected Graphs

Graphs

* Property of STI

Page 3 of 17

Data Structures

Graphs

Directed and Weighted Graphs

direction

Directed graphs - model situations in which

can go in only one direction along an edge

Weight - a number that can represent the

physical distance between two vertices

Historical Information

Graphs

* Property of STI

Page 4 of 17

Data Structures

Graphs

Vertices

class Vertex

{

public char label;

public boolean wasVisited;

public Vertex(char lab)

{

label = lab;

wasVisited = false;

}

}

Graphs

* Property of STI

Page 5 of 17

Data Structures

Graphs

Adjacency Matrix

Graphs

elements indicate whether an edge is

present between two vertices

* Property of STI

Page 6 of 17

Data Structures

Graphs

Adjacency List

Graphs

the discussion of recursion

* Property of STI

Page 7 of 17

Data Structures

Graphs

Adding Vertices and Edges to a Graph

Creation of vertex

addjMat[1][3] = 1;

addjMat[3][1] = 1;

Graphs

* Property of STI

Page 8 of 17

Data Structures

Graphs

class Graph

{

private final int MAX_VERTS = 20;

private Vertex vertexList[];

private int adjMat[][];

private int nVerts;

public Graph()

{

vertexList = new Vertex[MAX_VERTS];

adjMat = new int[MAX_VERTS][MAX_VERTS];

nVerts = 0;

for(int j=0; j<MAX_VERTS; j++)

for(int k=0; k<MAX_VERTS; k++)

adjMat[j][k] = 0;

theQueue = new Queue();

}

public void addVertex(char lab)

{

vertexList[nVerts++] = new Vertex(lab);

}

public void addEdge(int start, int end)

{

adjMat[start][end] = 1;

adjMat[end][start] = 1;

}

public void displayVertex(int v)

{

System.out.print(vertexList[v].label);

}

}

Graphs

* Property of STI

Page 9 of 17

Data Structures

Searches

Depth-First Search

Graphs

unvisited vertex, mark it, and push it on the

stack.

Rule 2: If you cant follow Rule 1, then, if

possible, pop vertex off the stack.

Rule 3: If you cant follow Rule 1 and Rule

2, its finished.

* Property of STI

Page 10 of 17

Data Structures

Searches

Depth-First Search

{

for(int j=0; j<nVerts; j++)

if(adjMat[v][j]==1 &&

vertexList[j].wasVisited==false)

return j;

return -1;

} \

Graphs

* Property of STI

Page 11 of 17

Data Structures

Searches

Depth-First Search

public void dfs()

{

vertexList[0].wasVisited = true;

displayVertex(0);

theStack.push(0);

while( !theStack.isEmpty() )

{

int v = getAdjUnvisitedVertex

( theStack.peek() );

if(v == -1)

theStack.pop();

else

{

vertexList[v].wasVisited = true;

displayVertex(v);

theStack.push(v);

}

}

for(int j=0; j<nVerts; j++)

vertexList[j].wasVisited = false;

}

Graphs

* Property of STI

Page 12 of 17

Data Structures

Searches

Depth-First Search creating a graph object

Graph theGraph = new Graph();

theGraph.addVertex('A');

theGraph.addVertex('B');

theGraph.addVertex('C');

theGraph.addVertex('D');

theGraph.addVertex('E');

theGraph.addEdge(0, 1);

theGraph.addEdge(1, 2);

theGraph.addEdge(0, 3);

theGraph.addEdge(3, 4);

System.out.print("Visits: ");

theGraph.dfs();

System.out.println();

Graphs

* Property of STI

Page 13 of 17

Data Structures

Searches

Breadth-First Search - stay as close as

possible to the starting point

Graphs

there is one) thats adjacent to the current

vertex, mark it, and insert it into the queue.

Rule 2: If you cant carry out Rule 1

because there are no more unvisited

vertices, remove a vertex from the queue (if

possible) and make it the current vertex.

Rule 3: If you cant carry out Rule 2

because the queue is empty, its finished.

* Property of STI

Page 14 of 17

Data Structures

Searches

Breadth-First Search

Graphs

* Property of STI

Page 15 of 17

Data Structures

Searches

Breadth-First Search

public void bfs()

{

vertexList[0].wasVisited = true;

displayVertex(0);

theQueue.insert(0);

int v2;

while( !theQueue.isEmpty() )

{

int v1 = theQueue.remove();

while((v2=getAdjUnvisitedVertex(v1)) != -1)

{

vertexList[v2].wasVisited = true;

displayVertex(v2);

theQueue.insert(v2);

}

}

for(int j=0; j<nVerts; j++)

vertexList[j].wasVisited = false;

}

Graphs

* Property of STI

Page 16 of 17

Data Structures

while( !theStack.isEmpty() )

{

int currentVertex = theStack.peek();

int v =getAdjUnvisitedVertex(currentVertex);

if(v == -1)

theStack.pop();

else

{

vertexList[v].wasVisited = true;

theStack.push(v);

displayVertex(currentVertex);

displayVertex(v);

System.out.print(" ");

}

}

for(int j=0; j<nVerts; j++)

vertexList[j].wasVisited = false;

}

Graphs

* Property of STI

Page 17 of 17

- ch10Uploaded byprasanth_223
- Albrecht Heeffer y Andreas M. Hinz - A difficult case. Pacioli and Cardano on the chinese ringsUploaded bylagatadezinc5733
- Graph Theory LectureUploaded byHakan KÜÇÜK
- ON BIPOLAR SINGLE VALUED NEUTROSOPHIC GRAPHSUploaded byAnonymous 0U9j6BLllB
- Graph Coloring in Parallel Processing and Scientific ComputingUploaded byGita Pramudya Saraswati
- Single-Valued Neutrosophic Graph StructuresUploaded byMia Amalia
- Unit v Graph_notesUploaded bykingraaja
- lab9Uploaded byKatneza Katman Mohlala
- DemokritosGR.proceedingsUploaded byPavel Mogilevsky
- 9783319405414-c2Uploaded by9810737971
- Graphs - DATA StructuresUploaded byAsadAliBhatti
- 00857718Uploaded bySandilla Tristiany
- SN_2014022715034583Uploaded byAlejandro Torres
- 633,Pretti,ConnectTheDots PresentationUploaded byAnonymous 5TdtcA
- Certain Properties of Bipolar Neutrosophic GraphsUploaded byMia Amalia
- R3_2Uploaded byAndersonOliveira
- math lesson planUploaded byapi-253462331
- Lecture 7 - Parser Evaluation, Lexicalized PCFG, Dependency Parsing Introduction - Evaluasi Parser Dan Dependency ParsingUploaded byDerryza
- MCS 033 NotesUploaded byAshik
- CAAUploaded byEDUARDOMOSTAJO
- 2008HarbinProblemSet.pdfUploaded byPhạm Hữu Thạnh Đạt
- Honors10_1PPUploaded byDoravari Lakshmi
- Iwanicki IR CS 045 2008Uploaded byIonela Neacsu
- WisFelKrue99-FaceRecognition-JainBook.pdfUploaded byArmine Carmina
- 10.1.1.93Uploaded bydanicco
- Computation of Shortest Path Problem in a Network with SV-Trapezoidal Neutrosophic NumbersUploaded byAnonymous 0U9j6BLllB
- Louis H. Kauffman- Problems Spring 2009Uploaded byOkomm
- riga-treUploaded byaravindmc
- 9fcfd50ff95a873897Uploaded byyuri_altus
- RF1902B46Uploaded byDewank Saini

- MELJUN CORTES Facebook Page Accounts ALL VIDEOS as FB.com/CORTES2525Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES Facebook Page Account as FB.com/CORTES2525Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES YOUTUBE Accounts Part 1Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES YOUTUBE Accounts Part 2Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES YOUTUBE Accounts Part 1Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES SOUND CLOUD AccountsUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES - TCU OSAS Strategic Planning 2019Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES - TCU OSAS Operational Planning 2019Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES - TCU OSAS Tactical Planning 2019Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES - DATA SCIENCE 4Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES - DATA SCIENCE 3Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES - DATA SCIENCE 2Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES - DATA SCIENCE 1Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES OJT 2019 ManualUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES Diploma Masteral MPA 2000Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES 3rd Metro South Research Congress March 2017Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES 4th Metro South Research Congress March 2017Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES 6th TCU University Research Festival August 2017Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN TCU Grades Transmittal CBM 2nd Semester 2018 2019 (June 6 2019)Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES IPCR June 2019 (Faculty Assistant of OSAS)Uploaded byMELJUN CORTES, MBA,MPA
- TCU Examine Masterlist Admission Report Batch 1 (April 7, 2019)Uploaded byMELJUN CORTES, MBA,MPA
- TCU Examine Masterlist Admission Report Batch 2 (April 14, 2019)Uploaded byMELJUN CORTES, MBA,MPA
- TCU Examine Masterlist Admission Report Batch 3 (April 28, 2019)Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES - MACHINE LEARNING Part 14Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES - MACHINE LEARNING Part 13Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES - MACHINE LEARNING Part 12Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES - MACHINE LEARNING Part 11Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES - MACHINE LEARNING Part 10Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES - MACHINE LEARNING Part 9Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES - MACHINE LEARNING Part 7Uploaded byMELJUN CORTES, MBA,MPA

- COLORING NUMBER AND ON-LINE RAMSEY THEORY FOR GRAPHS AND HYPERGRAPHSUploaded byAlex Nisnevich
- Final QuestionUploaded byShivani Sha
- Indefinite Integral Study Material Part 1 Hsslive RemeshUploaded byMathew Yoyakky
- Shortest Path ProblemUploaded byFRANCESCO222
- MTH202 Final Term 2009 PaperUploaded bycs619finalproject.com
- 02 Trigonometric IntegralsUploaded byAmita Angellae Guim
- Integral RulesUploaded byKARTHIK R K
- Compositions Partitions and Fibonacci NumbersUploaded byAndrei
- Game Theory_FergusonUploaded byLee Andrade
- Algebraic ThinkingUploaded byFarah Liyana
- COMP1805_ASSIGN04_(Model Solutions).pdfUploaded bySaif Rushdy
- Optimal Spanning TreesUploaded byPadmalatha Ragu
- Graph traversal.docxUploaded bynemonizer
- Cosine Hyperbolic FunctionUploaded byArial96
- Mth 221 Entire CourseUploaded byAdam
- MatchingUploaded bycesarinarraga
- Study Guide FinalUploaded byshivambarca
- Topological sort in DelphiUploaded byBrummer
- Max FlowUploaded bykyle_namgal1679
- CSM_Chapters7.pdfUploaded byClau Amaiia
- 50120140501010Uploaded byIAEME Publication
- 34Uploaded byAmaç Herdağdelen
- precUploaded bykunichiwa
- WI4Uploaded byAnonymous N3LpAX
- LADDER AND SUBDIVISION OF LADDER GRAPHS WITH PENDANT EDGES ARE ODD GRACEFULUploaded byMegan Bell
- Johnson’s AlgorithmUploaded byumar
- Ch 2 Inverse Trigo Multiple Choice Questions (With Answers)Uploaded byCRPF School
- Equitable Coloring on Triple Star Graph FamiliesUploaded byIoan Degau
- Counting TechniquesUploaded byrenj
- Getting Started in Sport of ProgrammingUploaded byashwani608