GitHub user dalaro opened a pull request:

    https://github.com/apache/tinkerpop/pull/372

    DSP-1397 Fix StarGraph addEdge for self-edges

    StarGraph has directionally-specific classes for its edges:
    
    * StarInEdge
    * StarOutEdge
    
    StarIn(/Out)Edges belong only in a StarVertex's in(/out)Edges map.  We
    see this assumption in StarVertex.applyGraphFilter, which invokes
    `graphFilter.legalEdges(this)` and then invokes `instanceof
    StarOutEdge` on each legal edge to determine its direction.
    
    This assumption was violated by the StarVertex.addEdge method.  This
    method special-cases self-edge addition.  This method first
    unconditionally adds a StarOutEdge.  Then, it checks to see whether
    its parameters indicate that it is adding a self-edge.  If this is so,
    the method proceeds to add that same StarOutEdge instance to the
    inEdges map.  This is the problem.  Adding a self-edge to a StarVertex
    results in one StarOutEdge instance that belongs to both the inEdges
    and outEdges map, which later causes the `applyGraphFilter` method's
    `instanceof` checks to yield two out edges and no in edges on a
    self-loop.
    
    This commit changes StarVertex so that self-edges are represented
    by a new class, StarSelfEdge.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dalaro/incubator-tinkerpop DSP-1397

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/tinkerpop/pull/372.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #372
    
----
commit dddc44369e2c645a854b2a7bed0f4af51acd6fc5
Author: Dan LaRocque <[email protected]>
Date:   2016-08-04T04:41:44Z

    DSP-1397 Fix StarGraph addEdge for self-edges
    
    StarGraph has directionally-specific classes for its edges:
    
    * StarInEdge
    * StarOutEdge
    
    StarIn(/Out)Edges belong only in a StarVertex's in(/out)Edges map.  We
    see this assumption in StarVertex.applyGraphFilter, which invokes
    `graphFilter.legalEdges(this)` and then invokes `instanceof
    StarOutEdge` on each legal edge to determine its direction.
    
    This assumption was violated by the StarVertex.addEdge method.  This
    method special-cases self-edge addition.  This method first
    unconditionally adds a StarOutEdge.  Then, it checks to see whether
    its parameters indicate that it is adding a self-edge.  If this is so,
    the method proceeds to add that same StarOutEdge instance to the
    inEdges map.  This is the problem.  Adding a self-edge to a StarVertex
    results in one StarOutEdge instance that belongs to both the inEdges
    and outEdges map, which later causes the `applyGraphFilter` method's
    `instanceof` checks to yield two out edges and no in edges on a
    self-loop.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to