DOC PREVIEW
Princeton COS 226 - UNDIRECTED GRAPHS

This preview shows page 1-2-3-4-5-6 out of 17 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Algorithms, 4th Edition·Robert Sedgewick and Kevin Wayne·Copyright © 2002–2012·March 26, 2012 5:38:13 AMAlgorithmsFOUR T H EDIT IONR O B E R T S EDG EWICK K EVIN W A Y N E4.1 UNDIRECTED GRAPHS‣graph API‣depth-first search‣breadth-first search‣connected components‣challengesGraph. Set of vertices connected pairwise by edges.Why study graph algorithms?•Thousands of practical applications. •Hundreds of graph algorithms known.•Interesting and broadly useful abstraction.•Challenging branch of computer science and discrete math.2Undirected graphs3Protein-protein interaction networkReference: Jeong et al, Nature Review | Genetics4The Internet as mapped by the Opte Projecthttp://en.wikipedia.org/wiki/Internet5Map of science clickstreamshttp://www.plosone.org/article/info:doi/10.1371/journal.pone.0004803610 million Facebook friends"Visualizing Friendships" by Paul Butler7One week of Enron emails8The evolution of FCC lobbying coalitions“The Evolution of FCC Lobbying Coalitions” by Pierre de Vries in JoSS Visualization Symposium 20109Framingham heart study“The Spread of Obesity in a Large Social Network over 32 Years” by Christakis and Fowler in New England Journal of Medicine, 2007The Spread of Obesity in a Large Social Network Over 32 Yearsn engl j med 357;4 www.nejm.org july 26, 2007373educational level; the ego’s obesity status at the previous time point (t); and most pertinent, the alter’s obesity status at times t and t + 1.25 We used generalized estimating equations to account for multiple observations of the same ego across examinations and across ego–alter pairs.26 We assumed an independent working correlation structure for the clusters.26,27The use of a time-lagged dependent variable (lagged to the previous examination) eliminated serial correlation in the errors (evaluated with a Lagrange multiplier test28) and also substantial-ly controlled for the ego’s genetic endowment and any intrinsic, stable predisposition to obesity. The use of a lagged independent variable for an alter’s weight status controlled for homophily.25 The key variable of interest was an alter’s obesity at time t + 1. A signif icant coefficient for this vari-able would suggest either that an alter’s weight affected an ego’s weight or that an ego and an alter experienced contemporaneous events affect-ing both their weights. We estimated these mod-els in varied ego–alter pair types.To evaluate the possibilit y that omitted vari-ables or unobserved events might explain the as-sociations, we examined how the type or direc-tion of the social relationship between the ego and the alter affected the association between the ego’s obesity and the alter’s obesity. For example, if unobserved factors drove the association be-tween the ego’s obesity and the alter’s obesity, then the directionality of friendship should not have been relevant.We evaluated the role of a possible spread in smoking-cessation behavior as a contributor to the spread of obesity by adding variables for the smoking status of egos and alters at times t and t + 1 to the foregoing models. We also analyzed the role of geographic distance between egos and alters by adding such a variable.We calculated 95% confidence intervals by sim-ulating the first difference in the alter’s contem-Figure 1. Largest Connected Subcomponent of the Social Network in the Framingham Heart Study in the Year 200 0.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 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.10Graph applicationsgraphvertexedgecommunicationtelephone, computerfiber optic cablecircuitgate, register, processorwiremechanicaljointrod, beam, springfinancialstock, currencytransactionstransportationstreet intersection, airporthighway, airway routeinternetclass C networkconnectiongameboard positionlegal movesocial relationshipperson, actorfriendship, movie castneural networkneuronsynapseprotein networkproteinprotein-protein interactionchemical compoundmoleculebond11Graph terminologyPath. Sequence of vertices connected by edges.Cycle. Path whose first and last vertices are the same.Two vertices are connected if there is a path between them.Anatomy of a graphcycle oflength 5vertexvertex ofdegree 3edgepath oflength 4connectedcomponents12Some graph-processing problemsPath. Is there a path between s and t ?Shortest path. What is the shortest path between s and t ?Cycle. Is there a cycle in the graph?Euler tour. Is there a cycle that uses each edge exactly once?Hamilton tour. Is there a cycle that uses each vertex exactly once? Connectivity. Is there a way to connect all of the vertices?MST. What is the best way to connect all of the vertices?Biconnectivity. Is there a vertex whose removal disconnects the graph?Planarity. Can you draw the graph in the plane with no crossing edges?Graph isomorphism. Do two adjacency lists represent the same graph?Challenge. Which of these problems are easy? difficult? intractable?13‣graph API‣depth-first search‣breadth-first search‣connected components‣challengesGraph drawing. Provides intuition about the structure of the graph.Caveat. Intuition can be misleading.14Graph representationTwo drawings of the same graphTwo drawings of the same graphtwo drawings of the same graphVertex representation.•This lecture: use integers between 0 and V – 1.•Applications: convert between names and integers with symbol table.Anomalies. AGECBFD15Graph representationsymbol table0642153Anomaliesparalleledgesself-loop16Graph API public class Graph public class GraphGraph(int V)Graph(int V)create an empty graph with V verticesGraph(In in)Graph(In in)create a graph from input streamvoidaddEdge(int v, int w)addEdge(int v, int w)add an edge v-wIterable<Integer>adj(int v)adj(int v)vertices adjacent to vint V()V()number of verticesint E()E()number of edgesString toString()toString()string representationIn in = new


View Full Document

Princeton COS 226 - UNDIRECTED GRAPHS

Documents in this Course
QUICKSORT

QUICKSORT

14 pages

QUICKSORT

QUICKSORT

55 pages

STRINGS

STRINGS

69 pages

Lecture

Lecture

4 pages

STRINGS

STRINGS

18 pages

Hashing

Hashing

7 pages

MERGESORT

MERGESORT

14 pages

Quicksort

Quicksort

12 pages

Strings

Strings

10 pages

Overview

Overview

15 pages

Hashing

Hashing

13 pages

Mergesort

Mergesort

15 pages

Tries

Tries

13 pages

Final

Final

12 pages

Final

Final

12 pages

Mergesort

Mergesort

13 pages

Final

Final

10 pages

Load more
Download UNDIRECTED GRAPHS
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view UNDIRECTED GRAPHS and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view UNDIRECTED GRAPHS 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?