public static NodeType Neighbour <NodeType, EdgeType>(this IHas <INodeLogic <NodeType, EdgeType> > node, IHas <IEdgeLogic <NodeType, EdgeType> > edge) where NodeType : IHas <INodeLogic <NodeType, EdgeType> > where EdgeType : IHas <IEdgeLogic <NodeType, EdgeType> > { if (edge.Head().Equals(node)) { return(edge.Foot()); } if (edge.Foot().Equals(node)) { return(edge.Head()); } return(default(NodeType)); }