introduction to graphs
play

Introduction to Graphs nodes. edges between pairs of nodes. - PowerPoint PPT Presentation

Notation. Introduction to Graphs nodes. edges between pairs of nodes. Captures pairwise relationship between objects. Tyler


  1. ����������������� Notation. � ���� � �� � � Introduction to Graphs � �� � nodes. � �� � edges between pairs of nodes. � Captures pairwise relationship between objects. Tyler Moore � Graph size parameters: � ���� � � � ��� � ���� � � � � . CSE 3353, SMU, Dallas, TX Lecture 5 � ����������������������������� � ������������������������������������������������������������ Some slides created by or adapted from Dr. Kevin Wayne. For more information see � ������� � ���� http://www.cs.princeton.edu/~wayne/kleinberg-tardos 3 2 / 24 ������������������������ ���������������������������������������� �������������������������������������������������������������������������������������������������� 4 5 3 / 24 4 / 24

  2. Social Network as a Graph ���������������������� Nodes: people Alice Edges: friendship Bob Charlie Dawn Eve Figure 1. Largest Connected Subcomponent of the Social N etwork in the Framingham H eart Study in the Year 2000. Each circle (node) represents one person in the data set. There are 2200 persons in this subcomponent of the social network. Circles with red borders denote women, and circles with blue borders denote men. The size of each circle George Fred is proportional to the person’s body-mass index. The interior color of the circles indicates the person’s obesity status: yellow denotes an obese person (body-mass index, ≥ 30) and green denotes a nonobese person. The colors of the ties between the nodes indicate the relationship between them: purple denotes a friendship or marital tie and orange denotes a familial tie. ��������������������������������������������������������������������������������������������������������������������������������� 6 5 / 24 6 / 24 Road Network as a Graph Electronic Circuits as a Graph 10 Ω Nodes: intersections A Main St Edges: roads v x S 20 Ω 5 Ω 5 v x 2nd Ave 1st Ave Main St Elm St B 3rd Ave Aspen Ave Main St Park St 5th Ave Vertices: junctions Edges: components 5th Ave 7 / 24 8 / 24

  3. Course Dependencies as a Graph Maze as a Graph CSE 1341 CSE 1342 CSE 2353 CSE 2341 Nodes: courses Edges: prerequisites CSE 3353 Nodes: rooms; edges: doorways CSE 5338 10 / 24 11 / 24 Flavors of Graphs Directed vs. Undirected Graphs A Undirected A Directed B C B C The fi rst step in any graph problem is recognizing that you have a graph problem D E D E It’s not always obvious! The second step in any graph problem is determining which fl avor of F G F G graph you are dealing with Learning to talk the talk is an important part of walking the walk A graph G = ( V , E ) is undirected if edge ( x , y ) ∈ E implies that The fl avor of graph has a big impact on which algorithms are ( y , x ) is also in E appropriate and e ffi cient Road networks between cities are typically undirected Street networks within cities are almost always directed because of one-way streets What about online social networks? 12 / 24 13 / 24

  4. ����������������������� �������������������������������� directed graph node directed edge graph node edge transportation street intersection one-way street communication telephone, computer fiber optic cable web web page hyperlink circuit gate, register, processor wire food web species predator-prey relationship mechanical joint rod, beam, spring WordNet synset hypernym financial stock, currency transactions scheduling task precedence constraint transportation street intersection, airport highway, airway route financial bank transaction internet class C network connection cell phone person placed call infectious disease person infection game board position legal move game board position legal move social relationship person, actor friendship, movie cast citation journal article citation neural network neuron synapse object graph object pointer protein network protein protein-protein interaction inheritance hierarchy class inherits from molecule atom bond control flow code block jump 7 39 13 / 24 14 / 24 Weighted vs. Unweighted Graphs Simple vs. Non-simple Graphs Unweighted Weighted Simple Non-simple A A A A 10 4 B C B C B C B C 1 7 5 8 19 D E D E D E D E 4 10 6 8 F G F G F G F G Certain types of edges complicate the task of working with graphs. A In weighted graphs, each edge (or vertex) of G is assigned a self-loop is an edge ( x , x ) involving only one vertex. numerical value, or weight An edge ( x , y ) is a multi-edge if it occurs more than once in the The edges of a road network graph might be weighted with their graph. length, drive-time or speed limit Any graph without self-loops and multi-edges is called simple. In unweighted graphs, there is no cost distinction between various edges and vertices Which of the earlier example graphs can be non-simple? 15 / 24 16 / 24

  5. Sparse vs. Dense Graphs Cyclic vs. Acyclic Graphs Sparse A A Dense Cyclic Acyclic A A B C B C B C B C D E D E D D F G F G F G F G Graphs are sparse when only a small fraction of the possible number An acyclic graph does not contain any cycles of vertex pairs actually have edges de fi ned between them. Trees are connected, acyclic, undirected graphs Graphs are usually sparse due to application-speci fi c constraints Directed acyclic graphs are called DAGs Road networks must be sparse because of road junctions DAGs arise naturally in scheduling problems, where a directed edge Typically dense graphs have a quadratic number of edges while sparse ( x , y ) indicates that x must occur before y . graphs are linear in size 17 / 24 18 / 24 Labeled vs. Unlabeled Graphs More Graph Terminology A Labeled Unlabeled B C A path is a sequence of edges connecting two vertices Two common problems: (1) does a path exist between A and B ? (2) D E what is the shortest path between A and B ? A graph is connected if there is a path between any two vertices F G A directed graph is strongly connected if there is a directed path between any two vertices. In labeled graphs, each vertex is assigned a unique name or identi fi er The degree of a vertex is the number of edges adjacent to it to distinguish it from all other vertices. An important graph problem is isomorphism testing: determining whether the topological structure of two graphs are in fact identical if we ignore any labels. 19 / 24 20 / 24

  6. ��������������������������������������� �������������������������������������� Adjacency matrix. � -by- � matrix with � �� ���� if � � �� � � is an edge. Adjacency lists. Node indexed array of lists. � Two representations of each edge. � Two representations of each edge. degree = number of neighbors of u � Space proportional to � � . � Space is Θ � � ��� � � . � Checking if � � �� � � is an edge takes Θ ��� time. � Checking if � � �� � � is an edge takes � � ������ � � �� time. � Identifying all edges takes Θ � � � � time. � Identifying all edges takes Θ � � ��� � � time. 1 2 3 1 2 3 4 5 6 7 8 2 1 3 4 5 1 0 1 1 0 0 0 0 0 2 1 0 1 1 1 0 0 0 3 1 2 5 7 8 3 1 1 0 0 1 0 1 1 4 2 5 4 0 1 0 0 1 0 0 0 5 2 3 4 6 5 0 1 1 1 0 1 0 0 6 0 0 0 0 1 0 0 0 5 6 7 0 0 1 0 0 0 0 1 7 3 8 8 0 0 1 0 0 0 1 0 8 3 7 8 9 21 / 24 22 / 24 Graph Data Structures Graph Data Structures Option 1: Adjacency Sets Option 2: Adjacency Lists a , b , c , d , e , f , g , h = range (8) a , b , c , d , e , f , g , h = range (8) N = [ N = [ { b , c , d , e , f } , # a [ b , c , d , e , f ] , # a { c , e } , # b [ c , e ] , # b { d } , # c [ d ] , # c g g c c b b { e } , # d [ e ] , # d { f } , # e [ f ] , # e { c , g , h } , # f [ c , g , h ] , # f { f , h } , # g [ f , h ] , # g a a f { f , g } # h f [ f , g ] # h ] ] > b i n N[ a ] > b i n N[ a ] > > > > e e d h # Neighborhood membership d h # Neighborhood membership True True > l e n (N[ f ] ) # Degree > l e n (N[ f ] ) # Degree > > > > 3 3 23 / 24 23 / 24

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend