Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
bb9781a0
Commit
bb9781a0
authored
Jan 25, 2024
by
Antoine Kaufmann
Committed by
Hejing Li
Feb 01, 2024
Browse files
experiments: add support for e2e partiton by weight
parent
65bdde67
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
experiments/simbricks/orchestration/e2e_partition.py
experiments/simbricks/orchestration/e2e_partition.py
+11
-2
No files found.
experiments/simbricks/orchestration/e2e_partition.py
View file @
bb9781a0
...
@@ -58,7 +58,7 @@ class IDMap(object):
...
@@ -58,7 +58,7 @@ class IDMap(object):
return
self
.
dict
.
items
()
return
self
.
dict
.
items
()
# Split the topology into N networks, return E2ENetwork instances
# Split the topology into N networks, return E2ENetwork instances
def
partition
(
topology
,
N
):
def
partition
(
topology
,
N
,
by_weight
=
False
):
adjlists
=
collections
.
defaultdict
(
tuple
)
adjlists
=
collections
.
defaultdict
(
tuple
)
edges
=
[]
edges
=
[]
idmap
=
IDMap
()
idmap
=
IDMap
()
...
@@ -78,14 +78,23 @@ def partition(topology, N):
...
@@ -78,14 +78,23 @@ def partition(topology, N):
max_node
=
max
(
adjlists
.
keys
())
max_node
=
max
(
adjlists
.
keys
())
graph
=
[]
graph
=
[]
weights
=
[]
for
i
in
range
(
0
,
max_node
+
1
):
for
i
in
range
(
0
,
max_node
+
1
):
c
=
idmap
.
from_id
(
i
)
if
'weight'
in
c
.
__dict__
:
weights
.
append
(
c
.
weight
)
else
:
weights
.
append
(
1
)
graph
.
append
(
adjlists
[
i
])
graph
.
append
(
adjlists
[
i
])
if
N
==
1
:
if
N
==
1
:
# metis does not like N=1 :-)
# metis does not like N=1 :-)
parts
=
[
0
]
*
(
max_node
+
1
)
parts
=
[
0
]
*
(
max_node
+
1
)
else
:
else
:
(
edgecuts
,
parts
)
=
metis
.
part_graph
(
graph
,
N
)
if
by_weight
:
(
edgecuts
,
parts
)
=
metis
.
part_graph
(
graph
,
N
,
nodew
=
weights
)
else
:
(
edgecuts
,
parts
)
=
metis
.
part_graph
(
graph
,
N
)
node_partitions
=
{}
node_partitions
=
{}
for
(
i
,
p
)
in
enumerate
(
parts
):
for
(
i
,
p
)
in
enumerate
(
parts
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment