Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mininet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olaf Bergmann
mininet
Commits
4a777024
Commit
4a777024
authored
11 years ago
by
Brian O'Connor
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of github.com:mininet/mininet
parents
15c1a0e5
9c4b7343
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mininet/topo.py
+7
-8
7 additions, 8 deletions
mininet/topo.py
with
7 additions
and
8 deletions
mininet/topo.py
+
7
−
8
View file @
4a777024
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
from
mininet.util
import
irange
,
natural
,
naturalSeq
from
mininet.util
import
irange
,
natural
,
naturalSeq
class
Graph
(
object
):
class
Multi
Graph
(
object
):
"
Utility class to track nodes and edges - replaces networkx.Graph
"
"
Utility class to track nodes and edges - replaces networkx.Graph
"
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -21,15 +21,14 @@ def __init__( self ):
...
@@ -21,15 +21,14 @@ def __init__( self ):
def
add_node
(
self
,
node
):
def
add_node
(
self
,
node
):
"
Add node to graph
"
"
Add node to graph
"
if
node
not
in
self
.
data
.
keys
():
self
.
data
.
setdefault
(
node
,
[]
)
self
.
data
[
node
]
=
[]
def
add_edge
(
self
,
src
,
dest
):
def
add_edge
(
self
,
src
,
dest
):
"
Add edge to graph
"
"
Add edge to graph
"
src
,
dest
=
sorted
(
(
src
,
dest
)
)
self
.
add_node
(
src
)
self
.
add_node
(
src
)
self
.
add_node
(
dest
)
self
.
add_node
(
dest
)
self
.
data
[
src
].
append
(
dest
)
self
.
data
[
src
].
append
(
dest
)
self
.
data
[
dest
].
append
(
src
)
def
nodes
(
self
):
def
nodes
(
self
):
"
Return list of graph nodes
"
"
Return list of graph nodes
"
...
@@ -54,7 +53,7 @@ def __init__(self, hopts=None, sopts=None, lopts=None):
...
@@ -54,7 +53,7 @@ def __init__(self, hopts=None, sopts=None, lopts=None):
hinfo: default host options
hinfo: default host options
sopts: default switch options
sopts: default switch options
lopts: default link options
"""
lopts: default link options
"""
self
.
g
=
Graph
()
self
.
g
=
Multi
Graph
()
self
.
node_info
=
{}
self
.
node_info
=
{}
self
.
link_info
=
{}
# (src, dst) tuples hash to EdgeInfo objects
self
.
link_info
=
{}
# (src, dst) tuples hash to EdgeInfo objects
self
.
hopts
=
{}
if
hopts
is
None
else
hopts
self
.
hopts
=
{}
if
hopts
is
None
else
hopts
...
@@ -256,9 +255,9 @@ def __init__(self, k=2, n=1, **opts):
...
@@ -256,9 +255,9 @@ def __init__(self, k=2, n=1, **opts):
switch
=
self
.
addSwitch
(
'
s%s
'
%
i
)
switch
=
self
.
addSwitch
(
'
s%s
'
%
i
)
# Add hosts to switch
# Add hosts to switch
for
j
in
irange
(
1
,
n
):
for
j
in
irange
(
1
,
n
):
hostNum
=
(
i
-
1
)
*
n
+
j
hostNum
=
(
i
-
1
)
*
n
+
j
host
=
self
.
addHost
(
'
h%s
'
%
hostNum
)
host
=
self
.
addHost
(
'
h%s
'
%
hostNum
)
self
.
addLink
(
host
,
switch
)
self
.
addLink
(
host
,
switch
)
# Connect switch to previous
# Connect switch to previous
if
lastSwitch
:
if
lastSwitch
:
self
.
addLink
(
switch
,
lastSwitch
)
self
.
addLink
(
switch
,
lastSwitch
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment