Fwd: New jgrapht questions for Feb 29 - Stack Exchange

8 views
Skip to first unread message

Joris Kinable

unread,
Mar 3, 2020, 10:28:03 AM3/3/20
to jgrapht-dev
Does anyone know a cleaner, more compact solution to the question below? My proposed solution seems rather verbose.

Joris Kinable

---------- Forwarded message ---------
From: Stack Exchange <do-not...@stackoverflow.email>
Date: Fri, Feb 28, 2020 at 9:31 PM
Subject: New jgrapht questions for Feb 29 - Stack Exchange
To: <j.ki...@gmail.com>


Stack Exchange

The following item was added to your Stack Exchange "jgrapht" feed.

Stack Overflow

Import graph with 1.4.0

I have very simple graph strict digraph G { &lt;assembly-raw-file&gt;; &lt;dataset-processing&gt;; &lt;feature-processing-1&gt;; &lt;feature-processing-2&gt;; ...

tagged: jgrapht Feb 29 at 2:00

Unsubscribe from this filter or change your email preferences by visiting your filter subscriptions page on stackexchange.com.

Questions? Comments? Let us know on our feedback site.

Stack Exchange Inc. 110 William Street, 28th floor, NY NY 10038 <3

Dimitrios Michail

unread,
Mar 3, 2020, 11:57:55 AM3/3/20
to jgrapht-dev
Not really. 

I opened up a small PR to see how to bring back this functionality. 

In some of the graph formats retaining the original id as the actual vertex might make sense, or at least is more user-friendly.

Similar functionality can be also be achieved if the user does the construction of the graph herself by creating a `DOTEventDrivenImporter` instead 
of a `GraphImporter`.

Best, 
Dimitrios

John Sichi

unread,
Mar 3, 2020, 8:23:59 PM3/3/20
to jgrapht-dev
Seems reasonable to me.  I'll merge the PR.

Dimitrios Michail

unread,
Mar 4, 2020, 5:13:34 AM3/4/20
to jgrapht-dev
If they use the snapshot branch then simply adding

`importer.setVertexFactory(id->id);`

in the importer will give them this functionality.

Only in case the user supplies such as factory, it is called with the vertex identifier from the file. The method given the vertex identifier from the 
file should return an actual graph vertex.  The user returned vertex is added directly into the graph without using the vertex supplier.

If no such factory is provided, the default behavior is to acquire a new vertex from the graph vertex supplier and associate the original identifier 
from the file as an attribute of the new vertex.

-- Dimitrios

Reply all
Reply to author
Forward
0 new messages