commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Tripodi <>
Subject Re: [Graph] Weighted as an interface
Date Mon, 05 Dec 2011 13:15:02 GMT
Hi Claudio,
so nice to see you are already deep in the spirit of the project! :)

> As for my suggestion on types, should I go for {{Weighted<N extends
> Number>}}?
> Note that I am also concerned about domain-specific requirements (e.g. all
> weights must be positive) that I would like to see implemented as
> "statically" as possible in the code. {{Number}} should give us quite enough
> freedom in that direction (e.g. one could later extend it with something
> like {{PositiveInteger}}).
> A more platonic alternative would be to have an abstract type of weight
> which 1. is comparable and 2. can be aggregated in some way (e.g. the weight
> of a path is the sum of weights of its edges). But I am probably going too
> far...

I think that is a valid idea, please don't stop and explore more! ;)

>> Moreover, I start having the feeling the {{WeightedGraph}} is a
>> useless interface: it is enough marking the vertices/edges as weighted
>> depending on the problem... or not? At the end of the day,
>> {{WeightedGraph}} does nothing than having the the edges marked as
>> weighted, so Dijkstra signature changed as:
>> <V extends Vertex, WE extends WeightedEdge, G extends DirectedGraph<V,
>> WE>>  WeightedPath<V, WE>  findShortestPath( G graph,  V source, V
>> target )
>> still define well the input type, a graph wich relations are directed
>> edges and edges are weighted... WDYT?
> I agree, as long as there are no specific features of the graph that are
> independent on its vertices and edges. Another advantage: I won't bother
> later to add more speficic interfaces like {{EdgeWeightedGraph}} or
> {{VertexWeightedGraph}} ;-)

+1, please include that in a separate issue!
All the best, have a nice day!

> Ciao,
> Claudio

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message