[jira] [Created] (SANDBOX-336) [Graph] Duplicate Edge

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (SANDBOX-336) [Graph] Duplicate Edge

David Costanzo (Jira)
[Graph] Duplicate Edge  
------------------------

                 Key: SANDBOX-336
                 URL: https://issues.apache.org/jira/browse/SANDBOX-336
             Project: Commons Sandbox
          Issue Type: Bug
          Components: Graph
            Reporter: Marco Speranza


The method  BaseMutableGraph#addEdge does not check if the edge already exists.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (SANDBOX-336) [Graph] Duplicate Edge

David Costanzo (Jira)

     [ https://issues.apache.org/jira/browse/SANDBOX-336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marco Speranza updated SANDBOX-336:
-----------------------------------

    Attachment: missingControllAlreadyExistEdge.patch

here is my patch.

> [Graph] Duplicate Edge  
> ------------------------
>
>                 Key: SANDBOX-336
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-336
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: Graph
>            Reporter: Marco Speranza
>         Attachments: missingControllAlreadyExistEdge.patch
>
>
> The method  BaseMutableGraph#addEdge does not check if the edge already exists.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (SANDBOX-336) [Graph] Duplicate Edge

David Costanzo (Jira)
In reply to this post by David Costanzo (Jira)

    [ https://issues.apache.org/jira/browse/SANDBOX-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13058819#comment-13058819 ]

Simone Tripodi commented on SANDBOX-336:
----------------------------------------

Hi Marco,
according to the Vertices checks the method already does, if an Edge between head/tail already exists, it should throw an exception, I mean:

{code}
if ( getEdge( head, tail ) != null )
{
    throw new GraphException( "Vertices '%s' and '%s' already present in the Graph", head, tail );
}
getAllEdges().add( e );
{code}

or not?

> [Graph] Duplicate Edge  
> ------------------------
>
>                 Key: SANDBOX-336
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-336
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: Graph
>            Reporter: Marco Speranza
>         Attachments: missingControllAlreadyExistEdge.patch
>
>
> The method  BaseMutableGraph#addEdge does not check if the edge already exists.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (SANDBOX-336) [Graph] Duplicate Edge

David Costanzo (Jira)
In reply to this post by David Costanzo (Jira)

    [ https://issues.apache.org/jira/browse/SANDBOX-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13058832#comment-13058832 ]

Marco Speranza commented on SANDBOX-336:
----------------------------------------

Hi Simo, I understand your point of view and I agree with you. I've only a remark:  the user should catch and manage the exception. Let me do an example:

To create a complete graph is usefull do this:
{code}
for ( BaseLabeledVertex v1 : g.getVertices() )
        {
            for ( BaseLabeledVertex v2 : g.getVertices() )
            {
                if ( !v1.equals( v2 ) )
                {
                      g.addEdge( v1, new BaseLabeledEdge( v1 + " -> " + v2 ), v2 );
                }
            }
        }
{code}

in this case the user should catch the exception, isn't it?
IMHO this is a little bit heavy. WDYT?

> [Graph] Duplicate Edge  
> ------------------------
>
>                 Key: SANDBOX-336
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-336
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: Graph
>            Reporter: Marco Speranza
>         Attachments: missingControllAlreadyExistEdge.patch
>
>
> The method  BaseMutableGraph#addEdge does not check if the edge already exists.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (SANDBOX-336) [Graph] Duplicate Edge

David Costanzo (Jira)
In reply to this post by David Costanzo (Jira)

    [ https://issues.apache.org/jira/browse/SANDBOX-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13058992#comment-13058992 ]

Simone Tripodi commented on SANDBOX-336:
----------------------------------------

Yes, clients that wants to automate Graphs generation have to manage/swallow the exceptions in that case.

{code}
for ( BaseLabeledVertex v1 : g.getVertices() )
{
    for ( BaseLabeledVertex v2 : g.getVertices() )
    {
        if ( !v1.equals( v2 ) )
        {
            try
            {
                g.addEdge( v1, new BaseLabeledEdge( v1 + " -> " + v2 ), v2 );
            }
            catch ( GraphException ge )
            {
                // do nothing
            }
        }
    }
}
{code}

> [Graph] Duplicate Edge  
> ------------------------
>
>                 Key: SANDBOX-336
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-336
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: Graph
>            Reporter: Marco Speranza
>         Attachments: missingControllAlreadyExistEdge.patch
>
>
> The method  BaseMutableGraph#addEdge does not check if the edge already exists.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (SANDBOX-336) [Graph] Duplicate Edge

David Costanzo (Jira)
In reply to this post by David Costanzo (Jira)

    [ https://issues.apache.org/jira/browse/SANDBOX-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13059021#comment-13059021 ]

Marco Speranza commented on SANDBOX-336:
----------------------------------------

OK Simo.. I've a proposal a little bit "vintage" :-)  
If addEdge() returned a boolean, true if the insert has been done, false otherwise, the users wouldn't force to manage/shallow the exception.

WDYT?

Ciao ciao have a nice week-end ;-)

> [Graph] Duplicate Edge  
> ------------------------
>
>                 Key: SANDBOX-336
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-336
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: Graph
>            Reporter: Marco Speranza
>         Attachments: missingControllAlreadyExistEdge.patch
>
>
> The method  BaseMutableGraph#addEdge does not check if the edge already exists.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (SANDBOX-336) [Graph] Duplicate Edge

David Costanzo (Jira)
In reply to this post by David Costanzo (Jira)

    [ https://issues.apache.org/jira/browse/SANDBOX-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13059030#comment-13059030 ]

Simone Tripodi commented on SANDBOX-336:
----------------------------------------

Interesting, but that would make more sense if the commons-graph would have been focused only on our in-memory based implementation. Looks like this is more a Graph generation turnaround that an APIs improvement.
I expect that in production environments people provide their {{Grap<V, E>}} implementation, adapting 3rd parties storages (GraphDB, KV-Storages, RDBMS...) so just providing a boolean flag of success/failure wouldn't be enough.
If an error happens in the data layers below Graph APIs, just returning {{false}} is a practice I have been discouraging, induces {{Grap<V, E>}} implementors kind of lazy pattern:

{code}
public void MyMutableGraph
{

    private MyGraphDBStorageInstance storage;

    ...

    public boolean addEdge( V head, E e, V tail )
    {
         try
         {
             storage.doSomething( head, e, tail );
             return true;
         }
         catch ( Throwable t )
         {
             return false;
         }
    }

    ...

}
{code}

OTOH, people could commit other mistakes - but I wouldn't offer them more chances to provide wrong implementations :P


> [Graph] Duplicate Edge  
> ------------------------
>
>                 Key: SANDBOX-336
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-336
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: Graph
>            Reporter: Marco Speranza
>         Attachments: missingControllAlreadyExistEdge.patch
>
>
> The method  BaseMutableGraph#addEdge does not check if the edge already exists.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (SANDBOX-336) [Graph] Duplicate Edge

David Costanzo (Jira)
In reply to this post by David Costanzo (Jira)

    [ https://issues.apache.org/jira/browse/SANDBOX-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13059093#comment-13059093 ]

Marco Speranza commented on SANDBOX-336:
----------------------------------------

ok Simo you're right, tomorrow I'll modify the patch in this way. thanks you for your comments :-)

ciaooo

> [Graph] Duplicate Edge  
> ------------------------
>
>                 Key: SANDBOX-336
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-336
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: Graph
>            Reporter: Marco Speranza
>         Attachments: missingControllAlreadyExistEdge.patch
>
>
> The method  BaseMutableGraph#addEdge does not check if the edge already exists.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (SANDBOX-336) [Graph] Duplicate Edge

David Costanzo (Jira)
In reply to this post by David Costanzo (Jira)

     [ https://issues.apache.org/jira/browse/SANDBOX-336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marco Speranza updated SANDBOX-336:
-----------------------------------

    Attachment: addDuplicatedEdgeCheck.patch

Here is the patch that contains the duplicated edge control.

> [Graph] Duplicate Edge  
> ------------------------
>
>                 Key: SANDBOX-336
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-336
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: Graph
>            Reporter: Marco Speranza
>         Attachments: addDuplicatedEdgeCheck.patch, missingControllAlreadyExistEdge.patch
>
>
> The method  BaseMutableGraph#addEdge does not check if the edge already exists.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (SANDBOX-336) [Graph] Duplicate Edge

David Costanzo (Jira)
In reply to this post by David Costanzo (Jira)

    [ https://issues.apache.org/jira/browse/SANDBOX-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13059253#comment-13059253 ]

Simone Tripodi commented on SANDBOX-336:
----------------------------------------

Thanks for the patch!!! :)

unfortunately source provided here is out-of-sync with /trunk, I got a compile error

{code}
commons-graph/src/test/java/org/apache/commons/graph/coloring/GraphColoringTestCase.java:[150,50] buildSudokuGraph(org.apache.commons.graph.model.UndirectedMutableGraph<org.apache.commons.graph.model.BaseLabeledVertex,org.apache.commons.graph.model.BaseLabeledEdge>) in org.apache.commons.graph.utils.GraphUtils cannot be applied to ()
{code}

did you prepared this patch in order [SANDBOX-335] has to be applied first?
Thanks in advance!!!
;)

> [Graph] Duplicate Edge  
> ------------------------
>
>                 Key: SANDBOX-336
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-336
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: Graph
>            Reporter: Marco Speranza
>         Attachments: addDuplicatedEdgeCheck.patch, missingControllAlreadyExistEdge.patch
>
>
> The method  BaseMutableGraph#addEdge does not check if the edge already exists.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (SANDBOX-336) [Graph] Duplicate Edge

David Costanzo (Jira)
In reply to this post by David Costanzo (Jira)

     [ https://issues.apache.org/jira/browse/SANDBOX-336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marco Speranza updated SANDBOX-336:
-----------------------------------

    Attachment:     (was: addDuplicatedEdgeCheck.patch)

> [Graph] Duplicate Edge  
> ------------------------
>
>                 Key: SANDBOX-336
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-336
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: Graph
>            Reporter: Marco Speranza
>         Attachments: missingControllAlreadyExistEdge.patch
>
>
> The method  BaseMutableGraph#addEdge does not check if the edge already exists.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (SANDBOX-336) [Graph] Duplicate Edge

David Costanzo (Jira)
In reply to this post by David Costanzo (Jira)

     [ https://issues.apache.org/jira/browse/SANDBOX-336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marco Speranza updated SANDBOX-336:
-----------------------------------

    Attachment: addDuplicatedEdgeCheck.patch

> [Graph] Duplicate Edge  
> ------------------------
>
>                 Key: SANDBOX-336
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-336
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: Graph
>            Reporter: Marco Speranza
>         Attachments: addDuplicatedEdgeCheck.patch, missingControllAlreadyExistEdge.patch
>
>
> The method  BaseMutableGraph#addEdge does not check if the edge already exists.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (SANDBOX-336) [Graph] Duplicate Edge

David Costanzo (Jira)
In reply to this post by David Costanzo (Jira)

    [ https://issues.apache.org/jira/browse/SANDBOX-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13059281#comment-13059281 ]

Marco Speranza commented on SANDBOX-336:
----------------------------------------

Ok simo, I fixed both patch SANDBOX-335 and this. sorry for that ;)

ciao

> [Graph] Duplicate Edge  
> ------------------------
>
>                 Key: SANDBOX-336
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-336
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: Graph
>            Reporter: Marco Speranza
>         Attachments: addDuplicatedEdgeCheck.patch, missingControllAlreadyExistEdge.patch
>
>
> The method  BaseMutableGraph#addEdge does not check if the edge already exists.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (SANDBOX-336) [Graph] Duplicate Edge

David Costanzo (Jira)
In reply to this post by David Costanzo (Jira)

     [ https://issues.apache.org/jira/browse/SANDBOX-336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Simone Tripodi resolved SANDBOX-336.
------------------------------------

    Resolution: Fixed
      Assignee: Simone Tripodi

Patch applied on [r1142965|http://svn.apache.org/viewvc?view=revision&revision=1142965], thanks once again for providing a patch!

> [Graph] Duplicate Edge  
> ------------------------
>
>                 Key: SANDBOX-336
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-336
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: Graph
>            Reporter: Marco Speranza
>            Assignee: Simone Tripodi
>         Attachments: addDuplicatedEdgeCheck.patch, missingControllAlreadyExistEdge.patch
>
>
> The method  BaseMutableGraph#addEdge does not check if the edge already exists.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira