|
From: Skye Bender-d. <sky...@sa...> - 2001-08-31 17:16:23
|
The way I've been doing it is to assume that people are either working with multiplex networks, or they arn't (hows that for logic!). So, for ex., all of the generation classes are either designed so that they will not create duplicate ties, or (I belive random net does this) you must explicity allow the possiblity of duplicate ties and self-loops. Many network statistics not meaningful if duplicate ties are allowed, but there are definitly some models where that is the way to go. So Density (the ratio of existing arcs to possible arcs in the network) will still return a reasonable value, but it is not really defined if you have multiplex ties, as you don't know what the max possbile num ties is. My soln. was to have calcDensity(ArrayList network) check if the network was multiplex, and throw a message. However this takes time, so I was also creating a method calcDensity(ArrayList network, boolean isMultiplx) If false, it would calc the density and return a value without checking for multplex (expensive) Method won't crash if the net was multi, just would return funny value. if isMultiplex is true, I was going to have it call a method, collapseMulti(ArralyList network) which would return the network with multiplex ties removed and calc the density. This pattern could be extened to other methods as well. Idea is that if they don't know what they are doing, things will be safe and slow, or if they know they've generated a network with no multiple ties, they can be fast. But, I realized that it would be dangerous to call collapseMulti from within another method, as it would delete the ties in the original network, hence the disire for a deep copy method. But it made me realise that there may be other (non-network) cases were people might want to perform operations on agents without actually modifying the "real" agents in the agent list. So perhaps we should implement Mikes suggestion, but as RepastUtilties.getDeepCopy(Object agent)? The other tricky thing is that getting a deep copy of a node would have to return a copy of the entire network it is connected to, otherwise if it still has the original edges, changing them would still change the original network. So, as I doubt we will figure all this out before i leave, I'll make sure collapseMulti is not called from within other methods, that it doesn't return (to make it clear that it is chaging the pased network rather than returning a copy), and it is documented as dangerous! BTW, NetUtilities.isMultiplex(ArrayList network) is a great way to check if a construction algorithm is working correctly! best skye Nick Collier wrote: > > I think Mike's suggestion here is a good one. But a question, under what > conditions will there be duplicate ties. Is it something we can protect > against when ties are created, a switch to all multiplex networks, or an > exception is thrown? > > nick > > > -- > Nick Collier > Social Science Research Computing > University of Chicago > http://repast.sourceforge.net |