Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added New Hypergraph Matching Algorithms #157

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
8fa0503
new env
bonicim May 17, 2024
88a3c4e
Merge remote-tracking branch 'origin/master'
rotshira May 22, 2024
d177aab
test+algo
rotshira May 22, 2024
cf1dd09
test+algo - fix
rotshira May 23, 2024
8f13bba
mathcing algo
rotshira May 28, 2024
8e4746a
mathcing algo
rotshira May 28, 2024
ce45e5b
fixed correct doctest
nivmoti May 28, 2024
66c59f9
Merge remote-tracking branch 'origin/master'
nivmoti May 28, 2024
57f1c81
test
rotshira May 28, 2024
91e7142
fixed correct tests
nivmoti May 28, 2024
1d47083
Merge remote-tracking branch 'origin/master'
nivmoti May 28, 2024
44b897f
update test & algo
rotshira Jun 2, 2024
6be80e5
Merge remote-tracking branch 'origin/master'
rotshira Jun 2, 2024
62c44db
Greedy algorithm implementation
rotshira Jun 4, 2024
37df82a
iterated_sampling algorithm implementation
rotshira Jun 4, 2024
55ae566
iterated_sampling algorithm implementation
rotshira Jun 4, 2024
5dda9d9
HEDCS_matching
rotshira Jun 4, 2024
f1ca740
alGo 1+2 WORK
rotshira Jun 6, 2024
44e36bf
matching_algorithms 1+2+3 WORK
rotshira Jun 6, 2024
7b47222
tests classes 1+2+3 WORK
rotshira Jun 6, 2024
f2a35df
fix all
rotshira Jun 6, 2024
11b7011
fixed correct tests fixed the functions
nivmoti Jun 6, 2024
277ee71
fixed correct tests fixed the functions vol.2
nivmoti Jun 6, 2024
e260887
fixed correct tests fixed the functions vol.3
nivmoti Jun 11, 2024
cae3b6b
complete functions with test
nivmoti Jun 12, 2024
4b69793
Tests and algorithm - final
rotshira Jun 13, 2024
c71ad7e
Tests - final
rotshira Jun 19, 2024
4f89f00
add logging debug
nivmoti Jun 24, 2024
bc359a0
performance comparison
nivmoti Jun 25, 2024
ce7df25
performance comparison
rotshira Jun 26, 2024
ee479b9
logs
erelsgl Jul 1, 2024
ba97f47
logs
erelsgl Jul 1, 2024
1a25284
remove backup folder
erelsgl Jul 1, 2024
26879ae
Website - demonstration of the algorithm
rotshira Jul 10, 2024
8b11a78
website fix
nivmoti Jul 11, 2024
184080b
Turtial notebook
nivmoti Jul 17, 2024
44b7f77
Merge remote-tracking branch 'origin/master'
nivmoti Jul 17, 2024
5f2143d
Update matching_algorithms_tutorial.ipynb
nivmoti Jul 24, 2024
5182eac
fixing problems
nivmoti Jul 29, 2024
bd68ec5
fixing problems
nivmoti Jul 29, 2024
44794e6
Merge branch 'master' into master
nivmoti Jul 29, 2024
43bef53
Merge remote-tracking branch 'upstream/master'
nivmoti Jul 30, 2024
a9363cd
Merge remote-tracking branch 'origin/master'
nivmoti Jul 30, 2024
244bccd
put the app website
nivmoti Jul 31, 2024
e651635
fix problems
nivmoti Jul 31, 2024
239aaac
Matching Algorithms pull changes
nivmoti Aug 25, 2024
98cdb92
Merge branch 'master' into master
erelsgl Sep 2, 2024
48e7b3c
Delete hypernetx/algorithms/cc.py
rotshira Sep 2, 2024
517131c
Update __init__.py
rotshira Sep 2, 2024
acb908e
Update Advanced 6 - Hypergraph Modularity and Clustering.ipynb
rotshira Sep 2, 2024
cb27fb3
Update Advanced 6 - Hypergraph Modularity and Clustering.ipynb
rotshira Sep 2, 2024
b388b91
Update __init__.py
nivmoti Sep 11, 2024
17c6862
Matching Algorithms pull changes
nivmoti Sep 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
website fix
nivmoti authored Jul 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 8b11a78c7424441b79d72d57f0c74b6c660a7aa5
56 changes: 56 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from flask import Flask, render_template, request
import random
from hypernetx.classes.hypergraph import Hypergraph
from hypernetx.algorithms.matching_algorithms import greedy_matching, iterated_sampling, HEDCS_matching

app = Flask(__name__)


def parse_hypergraph(data):
try:
edges = {}
for line in data.split('\n'):
if line.strip():
key, values = line.split(':')
edges[key.strip()] = list(map(int, values.split(',')))
return Hypergraph(edges)
except Exception as e:
raise ValueError(
"Input data is not in the correct format. Each line should be in the format 'edge: vertex1,vertex2,...'")


@app.route('/', methods=['GET', 'POST'])
def index():
error = None
form_data = {'hypergraph_data': '', 'k': '', 's': '', 'algorithm': ''}
if request.method == 'POST':
try:
hypergraph_data = request.form['hypergraph_data']
k = int(request.form['k'])
s = int(request.form['s'])
algorithm = request.form['algorithm']

hypergraph = parse_hypergraph(hypergraph_data)

if algorithm == 'greedy':
result = greedy_matching(hypergraph, k)
elif algorithm == 'iterated':
result = iterated_sampling(hypergraph, s)
elif algorithm == 'hedcs':
result = HEDCS_matching(hypergraph, s)
else:
result = "Invalid algorithm selected."

return render_template('result.html', data=hypergraph_data, result=result)
except ValueError as e:
error = str(e)
except Exception as e:
error = "An error occurred. Please ensure all inputs are correct."

form_data = request.form

return render_template('index.html', error=error, form_data=form_data)


if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)
Binary file added static/animated_hypergraph.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 97 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hypergraph Matching Algorithm</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<style>
body {
background-color: #e3f2fd;
font-family: Arial, sans-serif;
}
.container {
margin-top: 50px;
background: #ffffff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.form-group {
margin-bottom: 1.5rem;
}
.error-message {
color: red;
font-weight: bold;
}
.custom-btn {
background-color: #007bff;
color: white;
}
h1, h3 {
color: #007bff;
}

pre {
background-color: #f1f1f1;
color: #333;
padding: 10px;
border-radius: 5px;
}
.example-img {
max-width: 100%;
height: auto;
margin-top: 20px;
}
.animated-hypergraph {
margin-top: 20px;
text-align: center;
}
.highlight {
background-color: #ffeb3b;
}
</style>
</head>
<body>
<div class="container">
<h1 class="text-center">Hypergraph Matching Algorithm</h1>
<div class="row justify-content-center">
<div class="col-md-8">
{% if error %}
<p class="error-message">{{ error }}</p>
{% endif %}
<form method="post" action="{{ url_for('index') }}">
<div class="form-group">
<label for="hypergraph_data">Hypergraph Data (Format: edge: vertex1,vertex2,...)</label>
<textarea class="form-control" id="hypergraph_data" name="hypergraph_data" rows="6">{{ form_data.hypergraph_data }}</textarea>
</div>
<div class="form-group">
<label for="k">Number of Partitions (k)</label>
<input type="number" class="form-control" id="k" name="k" value="{{ form_data.k }}">
</div>
<div class="form-group">
<label for="s">Memory Size (s)</label>
<input type="number" class="form-control" id="s" name="s" value="{{ form_data.s }}">
</div>
<div class="form-group">
<label for="algorithm">Algorithm</label>
<select class="form-control" id="algorithm" name="algorithm">
<option value="greedy" {% if form_data.algorithm == 'greedy' %}selected{% endif %}>Greedy Matching</option>
<option value="iterated" {% if form_data.algorithm == 'iterated' %}selected{% endif %}>Iterated Sampling</option>
<option value="hedcs" {% if form_data.algorithm == 'hedcs' %}selected{% endif %}>HEDCS Matching</option>
</select>
</div>
<button type="submit" class="btn custom-btn">Submit</button>
</form>
<h3>Example Input:</h3>
<pre>e1: 1,2,3
e2: 2,3,4
e3: 1,4,5</pre>
<div class="animated-hypergraph">
<img src="{{ url_for('static', filename='animated_hypergraph.gif') }}" alt="Animated Hypergraph">
</div>
</div>
</div>
</div>
</body>
</html>

49 changes: 49 additions & 0 deletions templates/result.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hypergraph Matching Result</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<style>
body {
background-color: #e3f2fd;
font-family: Arial, sans-serif;
}
.container {
margin-top: 50px;
background: #ffffff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-btn {
background-color: #007bff;
color: white;
}
h1, h3 {
color: #007bff;
}
pre {
background-color: #f1f1f1;
color: #333;
padding: 10px;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="container">
<h1 class="text-center">Hypergraph Matching Result</h1>
<div class="row justify-content-center">
<div class="col-md-8">
<h3>Input Data:</h3>
<pre>{{ data }}</pre>
<h3>Result:</h3>
<pre>{{ result }}</pre>
<a href="/" class="btn custom-btn">Back</a>
</div>
</div>
</div>
</body>
</html>