Clarification on Repast edges

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

Clarification on Repast edges

Van Parunak
I've observed some (to me, unexpected) behavior of
repast.simphony.space.graph.NetworkBuilder, and would be grateful if
someone familiar with its innards would either confirm or correct this
summary.

1. When building an undirected graph, NetworkBuilder actually makes two
calls to the EdgeCreator, one in each direction. (At least, it calls my
EdgeCreator, which is the only thing I can put instrumentation in, twice.)
2. But if I retrieve all the edges from the finished graph, I don't get
one in each direction. I only get one edge, with the same object
identifier as the second of the two returned by EdgeCreator.
3. If I retrieve an edge from the finished graph, access its source and
target, then try to access an edge whose source is the target of the
first edge and whose target is the source of the first edge, I get the
very same edge back again. So the reverse edge has disappeared.

So it looks to me as though NetworkBuilder starts off by creating all
edges as directed, but if it detects two edges in reverse directions, it
a) keeps only the second one and b) marks it as undirected so that a
query with either end as source and the other end as target will succeed.

Have I got this approximately right?


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Clarification on Repast edges

srcnick
Van,

With what NetworkGenerator are you seeing this behavior?

Nick

> On May 1, 2017, at 2:21 PM, Van Parunak <[hidden email]> wrote:
>
> I've observed some (to me, unexpected) behavior of
> repast.simphony.space.graph.NetworkBuilder, and would be grateful if
> someone familiar with its innards would either confirm or correct this
> summary.
>
> 1. When building an undirected graph, NetworkBuilder actually makes two
> calls to the EdgeCreator, one in each direction. (At least, it calls my
> EdgeCreator, which is the only thing I can put instrumentation in, twice.)
> 2. But if I retrieve all the edges from the finished graph, I don't get
> one in each direction. I only get one edge, with the same object
> identifier as the second of the two returned by EdgeCreator.
> 3. If I retrieve an edge from the finished graph, access its source and
> target, then try to access an edge whose source is the target of the
> first edge and whose target is the source of the first edge, I get the
> very same edge back again. So the reverse edge has disappeared.
>
> So it looks to me as though NetworkBuilder starts off by creating all
> edges as directed, but if it detects two edges in reverse directions, it
> a) keeps only the second one and b) marks it as undirected so that a
> query with either end as source and the other end as target will succeed.
>
> Have I got this approximately right?
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Clarification on Repast edges

Van Parunak

I'm using Repast 2.4. The code is in the skeleton I sent  you before (https://www.dropbox.com/s/ncpskeqmm1v38bj/AssistInterface.zip?dl=0). AssistBuilder.java at lines 60-98 invokes the network builder twice (once for the pattern graph, once for the target graph), using my custom edge builder. The commented-out print statement at AssistEdgeCreator.java line 12 is what shows the generation of the two edges.

On 5/4/17 08:52, Nick Collier wrote:
Van,

With what NetworkGenerator are you seeing this behavior?

Nick

On May 1, 2017, at 2:21 PM, Van Parunak [hidden email] wrote:

I've observed some (to me, unexpected) behavior of 
repast.simphony.space.graph.NetworkBuilder, and would be grateful if 
someone familiar with its innards would either confirm or correct this 
summary.

1. When building an undirected graph, NetworkBuilder actually makes two 
calls to the EdgeCreator, one in each direction. (At least, it calls my 
EdgeCreator, which is the only thing I can put instrumentation in, twice.)
2. But if I retrieve all the edges from the finished graph, I don't get 
one in each direction. I only get one edge, with the same object 
identifier as the second of the two returned by EdgeCreator.
3. If I retrieve an edge from the finished graph, access its source and 
target, then try to access an edge whose source is the target of the 
first edge and whose target is the source of the first edge, I get the 
very same edge back again. So the reverse edge has disappeared.

So it looks to me as though NetworkBuilder starts off by creating all 
edges as directed, but if it detects two edges in reverse directions, it 
a) keeps only the second one and b) marks it as undirected so that a 
query with either end as source and the other end as target will succeed.

Have I got this approximately right?


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest

    

--
H. Van Dyke Parunak, Ph.D.
President, ABC Research, LLC

Superior solutions through Agent-Based and Complex systems
1027 Ferdon Road
Ann Arbor, MI 48104-3630
email: van.parunak@...
cell: 734 395 3253
www.ABCResearch.org

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Clarification on Repast edges

srcnick
It looks like you are using the ExcelNetworkLoader. That creates an  adjanceny matrix object and then we iterate through that creating an edge for each pair where the weight is not 0. So, two calls for the same edge could certainly occur there. As for what happens to those edges, the edges are ultimately passed to the JUNG Graph instance (https://github.com/jrtom/jung) that forms the basis of our networks. Part of what’s passed when the edge is added to the jung graph is the network type (directed or undirected). The JUNG Graph object then handles the rest depending on the network type. Hope that helps,

Nick

On May 4, 2017, at 11:33 AM, Van Parunak <[hidden email]> wrote:

I'm using Repast 2.4. The code is in the skeleton I sent  you before (https://www.dropbox.com/s/ncpskeqmm1v38bj/AssistInterface.zip?dl=0). AssistBuilder.java at lines 60-98 invokes the network builder twice (once for the pattern graph, once for the target graph), using my custom edge builder. The commented-out print statement at AssistEdgeCreator.java line 12 is what shows the generation of the two edges.

On 5/4/17 08:52, Nick Collier wrote:
Van,

With what NetworkGenerator are you seeing this behavior?

Nick

On May 1, 2017, at 2:21 PM, Van Parunak [hidden email] wrote:

I've observed some (to me, unexpected) behavior of 
repast.simphony.space.graph.NetworkBuilder, and would be grateful if 
someone familiar with its innards would either confirm or correct this 
summary.

1. When building an undirected graph, NetworkBuilder actually makes two 
calls to the EdgeCreator, one in each direction. (At least, it calls my 
EdgeCreator, which is the only thing I can put instrumentation in, twice.)
2. But if I retrieve all the edges from the finished graph, I don't get 
one in each direction. I only get one edge, with the same object 
identifier as the second of the two returned by EdgeCreator.
3. If I retrieve an edge from the finished graph, access its source and 
target, then try to access an edge whose source is the target of the 
first edge and whose target is the source of the first edge, I get the 
very same edge back again. So the reverse edge has disappeared.

So it looks to me as though NetworkBuilder starts off by creating all 
edges as directed, but if it detects two edges in reverse directions, it 
a) keeps only the second one and b) marks it as undirected so that a 
query with either end as source and the other end as target will succeed.

Have I got this approximately right?


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest

    

--
H. Van Dyke Parunak, Ph.D.
President, ABC Research, LLC
<LogoColorArtNouveau_Small.png>
Superior solutions through Agent-Based and Complex systems
1027 Ferdon Road
Ann Arbor, MI 48104-3630
email: <a href="x-msg://33/van.parunak@gmail.com" class="">van.parunak@...
cell: 734 395 3253
www.ABCResearch.org


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Clarification on Repast edges

Van Parunak

That makes a lot of sense. So if I entered only a half-matrix in Excel, while specifying "undirected," I'd still get my full graph, but omit the extra calls. Thanks!


On 5/5/17 09:28, Nicholson Collier wrote:
It looks like you are using the ExcelNetworkLoader. That creates an  adjanceny matrix object and then we iterate through that creating an edge for each pair where the weight is not 0. So, two calls for the same edge could certainly occur there. As for what happens to those edges, the edges are ultimately passed to the JUNG Graph instance (https://github.com/jrtom/jung) that forms the basis of our networks. Part of what’s passed when the edge is added to the jung graph is the network type (directed or undirected). The JUNG Graph object then handles the rest depending on the network type. Hope that helps,

Nick

On May 4, 2017, at 11:33 AM, Van Parunak <[hidden email]> wrote:

I'm using Repast 2.4. The code is in the skeleton I sent  you before (https://www.dropbox.com/s/ncpskeqmm1v38bj/AssistInterface.zip?dl=0). AssistBuilder.java at lines 60-98 invokes the network builder twice (once for the pattern graph, once for the target graph), using my custom edge builder. The commented-out print statement at AssistEdgeCreator.java line 12 is what shows the generation of the two edges.

On 5/4/17 08:52, Nick Collier wrote:
Van,

With what NetworkGenerator are you seeing this behavior?

Nick

On May 1, 2017, at 2:21 PM, Van Parunak [hidden email] wrote:

I've observed some (to me, unexpected) behavior of 
repast.simphony.space.graph.NetworkBuilder, and would be grateful if 
someone familiar with its innards would either confirm or correct this 
summary.

1. When building an undirected graph, NetworkBuilder actually makes two 
calls to the EdgeCreator, one in each direction. (At least, it calls my 
EdgeCreator, which is the only thing I can put instrumentation in, twice.)
2. But if I retrieve all the edges from the finished graph, I don't get 
one in each direction. I only get one edge, with the same object 
identifier as the second of the two returned by EdgeCreator.
3. If I retrieve an edge from the finished graph, access its source and 
target, then try to access an edge whose source is the target of the 
first edge and whose target is the source of the first edge, I get the 
very same edge back again. So the reverse edge has disappeared.

So it looks to me as though NetworkBuilder starts off by creating all 
edges as directed, but if it detects two edges in reverse directions, it 
a) keeps only the second one and b) marks it as undirected so that a 
query with either end as source and the other end as target will succeed.

Have I got this approximately right?


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest

--
H. Van Dyke Parunak, Ph.D.
President, ABC Research, LLC
<LogoColorArtNouveau_Small.png>
Superior solutions through Agent-Based and Complex systems
1027 Ferdon Road
Ann Arbor, MI 48104-3630
email: <a moz-do-not-send="true" href="x-msg://33/van.parunak@gmail.com" class="">van.parunak@...
cell: 734 395 3253
www.ABCResearch.org


--
H. Van Dyke Parunak, Ph.D.
President, ABC Research, LLC

Superior solutions through Agent-Based and Complex systems
1027 Ferdon Road
Ann Arbor, MI 48104-3630
email: van.parunak@...
cell: 734 395 3253
www.ABCResearch.org

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest