Skip to content

Denisplusplus/SSCC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Search for strongly-connected components

Kosaraju's algorithm:

  1. Perform a DFS of G and number the vertices in order of completion of the recursive calls.
  2. Construct a new directed graph Gr by reversing the direction of every arc in G.
  3. Perform a DFS on Gr starting the search from the highest numbered vertex according to the numbering assigned at step 1. If the DFS does not reach all vertices, start the next DFS from the highest numbered remaining vertex.
  4. Each tree in the resulting spanning forest is a strong component of G.

Structure of writing code for console version:

  • Reading the graph: we use adjacency matrix for assignment graph
  • Loop in the deph for original graph with topologigal sorted output list
  • Reverse original graph
  • Loop in the deph for reversion graph in toplological sorted order
  • Output components from step (1.4)- strongly-connected components

Structure of writing code for version with graphic interface:

  1. Interface part (JavaScript | OpenLayers3 | HTML | CSS):
    • Making the html page with certain design and sizes
    • Using OpenLayers3 as a library for creating graphs
    • Create empty sheet instead for the original map for recieving an ability to input the graph
    • The complexity of creating graphical dynamic objects is assumed by OpenLayers3- JS library
    • Creating the arrow and choosing the suitable design are our purposes
    • Final unit of the interface part is making the adjacent matrix for transfering to the server
  2. Server part (Python | CGI | Windows):
    • ///App--->cgi-bin/script.py-----index.html-----code.js----style.css----start.py//
    • start.py for starting the web-server on localhost:8000
    • index.html, code.js, style.css -frontend part
    • cgi-bin/script.py/ -server part
    • when user clicks the "Run button", JavaScript part sends AJAX request with adjacent matrix in JSON format to the server and then receives the answer-list of strongly-connected components and alert it

Testing the app:

For checking the correct working of our app we will use these pages with undeniable true examples:

As practice shows, the application is working correctly

Screenshots

Image alt Image alt Image alt Image alt

Links for better understanding algorithm and code: