Advice for Graphs with Verticies of Multiple Types

Aug 9, 2010 at 4:47 PM


I am having a problem with your IEdge<TVertex> interface because I have a graph that contains verticies of two types (IEntity and object).  Let me psuedo-code this out for you...

interface IEntity { // contents are unimportant }
interface IEntityRelator : IEdge<IEntity>  // this relates two entities
interface IMetadataProvider // I want this to relate an IEntity to an object.

I was wondering how you recommend I go forward?  Instead of assuming that an edge always connects Vertices of the same type, would it be possible to make IEdge<TVertex> instead be IEdge<TSource, TTarget>?  This would still allow an edge between vertices of one type (IEdge<IEntity, IEntity>), but would also allow edges between vertices of multiple types (IEdge<IEntity, object>).

Thank you for any advice you can offer,


Aug 12, 2010 at 11:09 PM

I got around this problem in my project by creating an abstract class to be the TVertex type, and then I had two subclasses for the two types of vertices I needed.