๐Ÿ’ก
My Docs
BlogLinkedin
WEB_DEV_JOB_SEARCH
WEB_DEV_JOB_SEARCH
  • Home
  • ๐ŸกHome
  • ๐Ÿ—บ๏ธNavigation
  • ๐Ÿ“ฅUseful Downloads
  • TO DO
    • Meetings:
    • Take Home Assignments
  • Jobs To Apply To
  • ๐Ÿ› ๏ธSkills
    • ๐ŸขMy Stack
    • E-Engineering
    • SQL / PSQL
  • ๐Ÿ“‹Filling Out Forms
  • ๐Ÿ“–Resources
    • Linkedin Cheat Shee
    • Job Search Advice
    • Orientation:
    • Links
    • Running List Of MISC Resources:
    • โ„๏ธCold Outreach Generator
  • Profiles
  • Linkedin
  • Examples
  • Resume
    • Resume
      • Certificate (Lambda)
      • Examples
      • Advice
      • Dice
      • Linkedin Resume
      • Indeed Resume
  • Applications
    • ๐Ÿ–ฑ๏ธTRACKING_APPLICATIONS
    • Amazon
  • Applications & Job Postings
    • Job Boards
      • More Job Boards
    • ๐Ÿ“ฎPostings:
      • Avid / Pro Tools
      • Amazon
      • My Applications
        • Application Info
        • In Progress
      • First Round Of Applications
      • Jobs To Keep Track Of
      • Recommended Jobs
  • Cover Letter
    • Cover Letter
      • CV-Guidance
    • More Advice
      • Practice Problems:
    • Example
    • Example Of Developer Bio
    • Old Engineering Cover Letter
  • Portfolio
    • ๐Ÿ’พGit Repo
    • ๐Ÿ–ผ๏ธPortfolio
  • ๐Ÿ“ˆSlack&Lambda
    • ๐Ÿ“บRecordings
    • ๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘๐Ÿง‘๐Ÿค๐Ÿง‘ ๐Ÿง‘๐Ÿค๐Ÿง‘ ๐Ÿง‘People
  • Aux-Resources
    • Youtube
    • ๐Ÿ‘จโ€๐Ÿซ๐Ÿ‘จ๐Ÿซ ๐Ÿ‘จ๐Ÿซ ๐Ÿ‘จGuidance
  • ๐Ÿ–‹๏ธInterview Prep
    • INTERVIEW
    • ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘จ๐Ÿ’ป ๐Ÿ‘จ๐Ÿ’ป ๐Ÿ‘จ๐Ÿ’ป ๐Ÿ‘จ๐Ÿ’ป ๐Ÿ‘จ๐Ÿ’ป ๐Ÿ‘จ๐Ÿ’ป ๐Ÿ‘จ๐Ÿ’ป Leetcode
      • 37-Essential-Js-Questions
      • ๐Ÿ“ˆRubric
    • Resources
      • List of List
      • Cheat-Sheet
    • Cheat-Sheet-Raw
    • General Advice & Tips
      • Website Checklist
      • Phone Interview Advice
    • Overview
      • Data-Structures Q & A
    • Web Dev Interview Questions
      • FULL-STACK DEVELOPER INTERVIEW QUESTIONS AND ANSWERS
    • โ‰๏ธInterview Questions.
      • cross-site scripting attack (XSS) and how do you prevent it?
      • What are refs in React? When should they be used?
      • virtual DOM and why is it used in libraries/frameworks?
      • What does the following code evaluate to?
      • What is the this keyword and how does it work?
      • What are landmark roles and how can they be useful?
      • What is the difference between lexical scoping and dynamic scoping?
      • What is the difference between null and undefined?
      • What is CSS BEM?
      • What is HTML5 Web Storage? Explain localStorage and sessionStorage.
      • How can you avoid callback hells?
      • What is functional programming?
      • useful example of one?
      • What is an async function?
      • What is the difference between the equality operators == and ===?
      • use-strict
      • sync-vs-async
      • null-vs-undefined
      • promises
      • accessibility-tree
        • imperative-vs-declarative
      • bem
      • cors
      • alt-attribute
    • Qualitative Questions
      • Cheat Sheets
        • Python-VS-JS Cheat Sheet
        • ๐ŸPython
      • React Interview
        • React Questions:
      • Front End Questions
    • ๐ŸงฎDS_ALGO Practice:
      • Algorithms
      • Exampes
      • DS_ALGO_NOTES
        • The queue data structure (JS)(PY)
    • Behavorial
      • Python Subpage
      • DS_&_ALGO_STUDY_GUIDE
      • Intro 2 Graphs:
      • Graphs
        • Graph (py)
      • Free Code Camp
      • Types Of Data Structures
      • Arrays
      • Page 2
      • ๐Ÿฅ…Hash Tables
    • FANG PREP (medium article)
    • โฑ๏ธMore Practice:
    • 300 React Q & A's
      • ๐Ÿ’ธReact Tips
    • Redux
    • ๐Ÿ›•Examples
      • Representing A Graph:
      • Anagrams & Big O
        • Python Performance
        • Strongly Connected Graph
      • Gists
    • Common Knowledge Questions
  • Tutorials
    • Custom Outreach Message Generator
      • Common Questions
      • Self Introduction
  • Technical Interview Tutorial
  • Job Boards
    • ๐Ÿ“‹Job Boards
      • Less Promising Job Boards
      • LIST OF BOARDS
  • Networking
    • ๐Ÿ—“๏ธEvents
  • MISC
    • Articles To Read
    • Job Search Images
  • Notes
    • Interview Navigation
    • Notes
    • CSS Interview Prep Quiz
  • ๐Ÿ–จ๏ธInterviewing
    • General
    • Inspiration
    • Front End Interview
    • Common Questions
  • Networking
    • Networking
      • a/A Email List
    • Page 1
  • ๐Ÿ““ARCHIVE
    • Archive
      • โ‡๏ธSlack Announcements
    • Projects
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Interview Prep
  2. Examples
  3. Anagrams & Big O

Strongly Connected Graph

PreviousPython PerformanceNextGists

Last updated 3 years ago

Was this helpful?

For the remainder of this chapter we will turn our attention to some extremely large graphs. The graphs we will use to study some additional algorithms are the graphs produced by the connections between hosts on the Internet and the links between web pages. We will begin with web pages.

Search engines like Google and Bing exploit the fact that the pages on the web form a very large directed graph. To transform the World Wide Web into a graph, we will treat a page as a vertex, and the hyperlinks on the page as edges connecting one vertex to another. The illustration below shows a very small part of the graph produced by following the links from one page to the next, beginning at Luther Collegeโ€™s Computer Science home page. Of course, this graph could be huge, so we have limited it to web sites that are no more than 10 links away from the CS home page.

If you study the graph above you might make some interesting observations. First you might notice that many of the other web sites on the graph are other Luther College web sites. Second, you might notice that there are several links to other colleges in Iowa. Third, you might notice that there are several links to other liberal arts colleges. You might conclude from this that there is some underlying structure to the web that clusters together web sites that are similar on some level.

One graph algorithm that can help find clusters of highly interconnected vertices in a graph is called the strongly connected components algorithm (SCC). We formally define a strongly connected component, CCC, of a graph GGG, as the largest subset of vertices CโŠ‚VC \subset VCโŠ‚V such that for every pair of vertices v,wโˆˆCv, w \in Cv,wโˆˆC we have a path from vvv to www and a path from www to vvv. The illustration below shows a simple graph with three strongly connected components. The strongly connected components are identified by the different shaded areas.

Once the strongly connected components have been identified we can show a simplified view of the graph by combining all the vertices in one strongly connected component into a single larger vertex. The simplified version of the graph above is shown below.

Once again we will see that we can create a very powerful and efficient algorithm by making use of a depth first search. Before we tackle the main SCC algorithm we must look at one other definition. The transpose of a graph GGG is defined as the graph GTG^TGT where all the edges in the graph have been reversed. That is, if there is a directed edge from node A to node B in the original graph then GTG^TGT will contain an edge from node B to node A. The diagrams below show a simple graph and its transposition.

Notice that the graphs above have the same two strongly connected components.

We can now describe the algorithm to compute the strongly connected components for a graph.

  1. Perform a depth first search for the graph GGG to compute the finish times for each vertex.

  2. Compute GTG^TGT.

  3. Perform a depth first search for the graph GTG^TGT but in the main loop explore each vertex in decreasing order of finish time.

  4. Each tree in the forest computed in step 3 is a strongly connected component. Output the vertex ids for each vertex in each tree in the forest to identify the component.

Letโ€™s trace the operation of the steps described above on the example graph above with the three strongly connected components. Here are the start and finish times computed for the original graph:

Here are the starting and finishing times computed by on the transposed graph.

Finally, the illustration below shows the forest of three trees produced in step 3 of the strongly connected component algorithm. You will notice that we do not provide you with the Python code for the SCC algorithm, we leave writing this program as an exercise.

๐Ÿ–‹๏ธ
๐Ÿ›•