Skip to content

Commit

Permalink
feat: elevation to master (#205)
Browse files Browse the repository at this point in the history
* feat: delete testing files

* feat: visualisation

* feat: utils.py

* feat: stochastic.py

* feat: resilience.py

* feat: stochastic.py

* feat: rm report.py

* feat: preprocessing.py

* feat: NetworkGraphs.py

* feat: metrics.py

* feat: machineLearning.py

* feat: deepLearning.py

* feat: embedding.py

* feat: rm classification.ipynb

* feat: metrics_visualisation.py

* feat: ML_visualisation.py

* feat: utils_visualisation.py

* refactor: cleaned up the codebase (#198)

* fix: issue with non-temporal graph in visualisation.html

* feat: stochastic api

* feat: Documentation (#201)

* chore: documentation

* feat: created documentation

* feat: created documentation

* feat: created documentation

* feat: created documentation

* feat: stochastic analysis integration (#203)

* Update resilience_routes.py

* feat: stochastic analysis

* Update stochastic.js

* feat: add tooltips

* fix: gtfs duplicate stations preprocess

---------

Co-authored-by: sferez <[email protected]>
Co-authored-by: Tejas Patil <[email protected]>
  • Loading branch information
3 people authored May 1, 2023
1 parent 456b109 commit 604cd92
Show file tree
Hide file tree
Showing 416 changed files with 37,585 additions and 4,867 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ venv/
.vscode/
.ipynb_checkpoints/
__pycache__/
application/__pycache__/
*.mp4
.env
.DS_Store
Expand All @@ -17,3 +18,4 @@ application/flask_session/
application/__pycache__/app.cpython-311.pyc
*.pyc
*.pyc
flask_session/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ WORKDIR /alpha-team

# Install GDAL and pygraphviz
RUN pip install GDAL pygraphviz

RUN pip3 install torch --index-url https://download.pytorch.org/whl/cpu
# Copy the current directory contents into the container at /AlphaTeam
COPY requirements.txt .

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ the command in step 3 above.

# Documentation

On the frontend of the application, you can find the documentation for the API endpoints once the frontend application
is started at `http://localhost:{chosen port}/docs`
You can view the documentation in the `docs/` directory. The documentation is generated using Sphinx.

### To regenerate the documentation
In the root directory of the project, run `sh generate_docs.sh` to regenerate the documentation.
140 changes: 0 additions & 140 deletions analysis/CryptoData.ipynb

This file was deleted.

770 changes: 0 additions & 770 deletions analysis/Rail.ipynb

This file was deleted.

2 changes: 2 additions & 0 deletions application/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from application.routes.hotspot.hotspot_routes import hotspot_routes
from application.routes.metrics.global_metrics_routes import global_metrics_routes
from application.routes.visualisation.visualisation_routes import visualisation_routes
from application.routes.stochastic.stochastic_routes import stochastic_routes

sys.path.insert(1, '../')
from src.NetworkGraphs import *
Expand All @@ -40,6 +41,7 @@
app.register_blueprint(hotspot_routes)
app.register_blueprint(global_metrics_routes)
app.register_blueprint(visualisation_routes)
app.register_blueprint(stochastic_routes)

BASE_URL = 'http://localhost:8000/api/v1'

Expand Down
Empty file.
17 changes: 16 additions & 1 deletion application/dictionary/information.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

'list_of_nodes': 'Enter a list of nodes to remove from the network for a personalized resilience analysis, '
'allowing you to evaluate the impact of specific node deletions on the overall network stability.',

}

description = {
Expand Down Expand Up @@ -141,7 +142,8 @@
"<b>closed loop of three nodes</b>. By examining the number of triangles a node participates in, "
"one can assess its tendency to form tightly connected groups. This metric helps identify nodes "
"that contribute to the network's <b>cohesion and community structure</b>, revealing potential "
"subgroups or areas of high connectivity.",
"subgroups or areas of high connectivity. <i>Triangle computation is not allow for Directed and "
"Multi graphs.</i>",

'node_pagerank': "Node PageRank is a metric that estimates a node's <b>relative importance</b> within a network, "
"considering both the <b>quantity and quality</b> of its connections. Inspired by the algorithm "
Expand Down Expand Up @@ -322,4 +324,17 @@
"groups similar nodes using their embeddings. This combination provides a more "
"comprehensive understanding of network organization, relationships between communities, "
"and individual node roles, unveiling shared interests or functional clusters.",

'clustering_coefficient': "The <b>Clustering Coefficient Estimator</b> provides a robust and efficient method for "
"computing the clustering coefficient in complex networks, without the computational "
"overhead of traditional techniques. Leveraging a <b>stochastic Monte Carlo "
"approach</b>, our algorithm performs the metrics computation over <b>10,"
"000 iterations</b>, ensuring accurate estimations while <b>significantly reducing "
"processing time</b>. ",

'shortest_path': "The <b>Shortest Path Length Estimator</b> provides an efficient and accurate estimation of the "
"shortest path length in complex networks, without the computational burden of traditional "
"methods. Utilizing a <b>stochastic Monte Carlo approach</b>, our algorithm samples the metrics "
"computation over <b>10,000 iterations</b>, ensuring reliable estimations while <b>significantly "
"reducing processing time</b>.",
}
291 changes: 195 additions & 96 deletions application/routes/centrality_routes.py

Large diffs are not rendered by default.

282 changes: 166 additions & 116 deletions application/routes/cluster_routes.py

Large diffs are not rendered by default.

Empty file.
136 changes: 97 additions & 39 deletions application/routes/clusters/cluster_routes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys

import requests
from flask import Blueprint, render_template, session

from application.dictionary.information import *
from flask import Blueprint, render_template, session, request

sys.path.insert(1, '../../')
from src.metrics import *
Expand All @@ -12,8 +12,14 @@
# -------------------------------------------ML-CLUSTERING-----------------------------------
BASE_URL = 'http://localhost:8000/api/v1/clusters/'


@cluster_routes.route('/clustering/louvain', endpoint='clustering_louvanian', methods=['GET', 'POST'])
def clustering_louvanian():
"""
:Function: Visualise the clusters using Louvain algorithm
:return: the cluster page
"""
filename2 = session['filename2']
clusterType = 'louvain'
networkGraphs = get_networkGraph(filename2)
Expand All @@ -22,14 +28,20 @@ def clustering_louvanian():
else:
is_spatial = 'no'

return render_template('clusters/clustering_louvanian.html', session_id=filename2, clusterType=clusterType, method_name='Louvain', is_spatial=is_spatial,
#tooltips starts from here
description=description['louvain'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'], tooltip_number_of_clusters=tooltips['number_of_clusters'])
return render_template('clusters/clustering_louvanian.html', session_id=filename2, clusterType=clusterType,
method_name='Louvain', is_spatial=is_spatial,
description=description['louvain'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'],
tooltip_number_of_clusters=tooltips['number_of_clusters'])


@cluster_routes.route('/clustering/greedy_modularity', endpoint='clustering_greedy_modularity', methods=['GET', 'POST'])
def clustering_greedy_modularity():
"""
:Function: Visualise the clusters using Greedy Modularity algorithm
:return: the clusters page
"""
filename2 = session['filename2']
clusterType = 'greedy_modularity'
networkGraphs = get_networkGraph(filename2)
Expand All @@ -38,15 +50,20 @@ def clustering_greedy_modularity():
else:
is_spatial = 'no'

return render_template('clusters/clustering_greedy_modularity.html', session_id=filename2, clusterType=clusterType, method_name='Greedy Modularity', is_spatial=is_spatial,
#tooltips starts from here
description=description['greedy_modularity'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'], tooltip_number_of_clusters=tooltips['number_of_clusters'])

return render_template('clusters/clustering_greedy_modularity.html', session_id=filename2, clusterType=clusterType,
method_name='Greedy Modularity', is_spatial=is_spatial,
description=description['greedy_modularity'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'],
tooltip_number_of_clusters=tooltips['number_of_clusters'])


@cluster_routes.route('/clustering/label_propagation', endpoint='clustering_label_propagation', methods=['GET', 'POST'])
def clustering_label_propagation():
"""
:Function: Visualise the clusters using Label Propagation algorithm
:return: the clusters page
"""
filename2 = session['filename2']
clusterType = 'label_propagation'
networkGraphs = get_networkGraph(filename2)
Expand All @@ -55,14 +72,20 @@ def clustering_label_propagation():
else:
is_spatial = 'no'

return render_template('clusters/clustering_label_propagation.html', session_id=filename2, clusterType=clusterType, method_name='Label Propagation', is_spatial=is_spatial,
#tooltips starts from here
description=description['label_propagation'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'], tooltip_number_of_clusters=tooltips['number_of_clusters'])
return render_template('clusters/clustering_label_propagation.html', session_id=filename2, clusterType=clusterType,
method_name='Label Propagation', is_spatial=is_spatial,
description=description['label_propagation'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'],
tooltip_number_of_clusters=tooltips['number_of_clusters'])


@cluster_routes.route('/clustering/asyn_lpa', endpoint='clustering_asyn_lpa', methods=['GET', 'POST'])
def clustering_asyn_lpa():
"""
:Function: Visualise the clusters using Asyn Lpa algorithm
:return: the clusters page
"""
filename2 = session['filename2']
clusterType = 'asyn_lpa'
networkGraphs = get_networkGraph(filename2)
Expand All @@ -71,13 +94,20 @@ def clustering_asyn_lpa():
else:
is_spatial = 'no'

return render_template('clusters/clustering_asyn_lpa.html', session_id=filename2, clusterType=clusterType, method_name='Asyn Lpa', is_spatial=is_spatial,
#tooltips starts from here
description=description['asyn_lpa'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'], tooltip_number_of_clusters=tooltips['number_of_clusters'])
return render_template('clusters/clustering_asyn_lpa.html', session_id=filename2, clusterType=clusterType,
method_name='Asyn Lpa', is_spatial=is_spatial,
description=description['asyn_lpa'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'],
tooltip_number_of_clusters=tooltips['number_of_clusters'])


@cluster_routes.route('/clustering/k_clique', endpoint='clustering_k_clique', methods=['GET', 'POST'])
def clustering_k_clique():
"""
:Function: Visualise the clusters using K Clique algorithm
:return: the clusters page
"""
filename2 = session['filename2']
clusterType = 'k_clique'
networkGraphs = get_networkGraph(filename2)
Expand All @@ -86,13 +116,20 @@ def clustering_k_clique():
else:
is_spatial = 'no'

return render_template('clusters/clustering_k_clique.html', session_id=filename2, clusterType=clusterType, method_name='K Clique', is_spatial=is_spatial,
#tooltips starts from here
description=description['k_clique'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'], tooltip_number_of_clusters=tooltips['number_of_clusters'])
return render_template('clusters/clustering_k_clique.html', session_id=filename2, clusterType=clusterType,
method_name='K Clique', is_spatial=is_spatial,
description=description['k_clique'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'],
tooltip_number_of_clusters=tooltips['number_of_clusters'])


@cluster_routes.route('/clustering/spectral', endpoint='clustering_spectral', methods=['GET', 'POST'])
def clustering_spectral():
"""
:Function: Visualise the clusters using Spectral algorithm
:return: the clusters page
"""
filename2 = session['filename2']
clusterType = 'spectral'
networkGraphs = get_networkGraph(filename2)
Expand All @@ -101,13 +138,20 @@ def clustering_spectral():
else:
is_spatial = 'no'

return render_template('clusters/clustering_spectral.html', session_id=filename2, clusterType=clusterType, method_name='Spectral', is_spatial=is_spatial,
#tooltips starts from here
description=description['spectral'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'], tooltip_number_of_clusters=tooltips['number_of_clusters'])
return render_template('clusters/clustering_spectral.html', session_id=filename2, clusterType=clusterType,
method_name='Spectral', is_spatial=is_spatial,
description=description['spectral'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'],
tooltip_number_of_clusters=tooltips['number_of_clusters'])


@cluster_routes.route('/clustering/kmeans', endpoint='clustering_kmeans', methods=['GET', 'POST'])
def clustering_kmeans():
"""
:Function: Visualise the clusters using KMeans algorithm
:return: the clusters page
"""
filename2 = session['filename2']
clusterType = 'kmeans'
networkGraphs = get_networkGraph(filename2)
Expand All @@ -116,13 +160,20 @@ def clustering_kmeans():
else:
is_spatial = 'no'

return render_template('clusters/clustering_kmeans.html', session_id=filename2, clusterType=clusterType, method_name='KMeans', is_spatial=is_spatial,
#tooltips starts from here
description=description['kmeans'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'], tooltip_number_of_clusters=tooltips['number_of_clusters'])
return render_template('clusters/clustering_kmeans.html', session_id=filename2, clusterType=clusterType,
method_name='KMeans', is_spatial=is_spatial,
description=description['kmeans'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'],
tooltip_number_of_clusters=tooltips['number_of_clusters'])


@cluster_routes.route('/clustering/agglomerative', endpoint='clustering_agglomerative', methods=['GET', 'POST'])
def clustering_agglomerative():
"""
:Function: Visualise the clusters using Agglomerative algorithm
:return: the clusters page
"""
filename2 = session['filename2']
clusterType = 'agglomerative'
networkGraphs = get_networkGraph(filename2)
Expand All @@ -131,14 +182,20 @@ def clustering_agglomerative():
else:
is_spatial = 'no'

return render_template('clusters/clustering_agglomerative.html', session_id=filename2, clusterType=clusterType, method_name='Agglomerative', is_spatial=is_spatial,
#tooltips starts from here
description=description['agglomerative'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'], tooltip_number_of_clusters=tooltips['number_of_clusters'])
return render_template('clusters/clustering_agglomerative.html', session_id=filename2, clusterType=clusterType,
method_name='Agglomerative', is_spatial=is_spatial,
description=description['agglomerative'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'],
tooltip_number_of_clusters=tooltips['number_of_clusters'])


@cluster_routes.route('/clustering/dbscan', endpoint='clustering_dbscan', methods=['GET', 'POST'])
def clustering_dbscan():
"""
:Function: Visualise the clusters using Dbscan algorithm
:return: the clusters page
"""
filename2 = session['filename2']
clusterType = 'dbscan'
networkGraphs = get_networkGraph(filename2)
Expand All @@ -147,7 +204,8 @@ def clustering_dbscan():
else:
is_spatial = 'no'

return render_template('clusters/clustering_dbscan.html', session_id=filename2, clusterType=clusterType, method_name='Dbscan', is_spatial=is_spatial,
#tooltips starts from here
description=description['dbscan'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'], tooltip_number_of_clusters=tooltips['number_of_clusters'])
return render_template('clusters/clustering_dbscan.html', session_id=filename2, clusterType=clusterType,
method_name='Dbscan', is_spatial=is_spatial,
description=description['dbscan'], tooltip_dynamic=tooltips['dynamic'],
tooltip_layout=tooltips['layout_dropdown'],
tooltip_number_of_clusters=tooltips['number_of_clusters'])
Empty file.
Loading

0 comments on commit 604cd92

Please sign in to comment.