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

bug in topo.py Topo.AddLink() #903

Open
alfsalte opened this issue Sep 17, 2019 · 2 comments
Open

bug in topo.py Topo.AddLink() #903

alfsalte opened this issue Sep 17, 2019 · 2 comments

Comments

@alfsalte
Copy link

The function AddLink() in topo.py in class Topo is in my version like this:

def addLink( self, node1, node2, port1=None, port2=None,
             key=None, **opts ):
    """node1, node2: nodes to link together
       port1, port2: ports (optional)
       opts: link options (optional)
       returns: link info key"""
    if not opts and self.lopts:
        opts = self.lopts
    port1, port2 = self.addPort( node1, node2, port1, port2 )
    opts = dict( opts )
    opts.update( node1=node1, node2=node2, port1=port1, port2=port2 )
    self.g.add_edge(node1, node2, key, opts )
    return key

The last line should be removed and the line before it should get the return, like this:
..... other code...
opts.update( node1=node1, node2=node2, port1=port1, port2=port2 )
return self.g.add_edge(node1, node2, key, opts )

The key argument in is by default None and Multigraph.add_edge will change the key if it is None to the actual key value and return the actual key. AddLink also have key as None by default and the present code simply returns the input key even if it is None.

Instead it should return the key it gets from add_edge so that it returns the actual key used.

@jadinm
Copy link
Contributor

jadinm commented Nov 25, 2019

The PR #895 will fix this issue when merged :)

@cheriimoya
Copy link
Contributor

PR is merged, this can be closed @lantz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants