public static bool AreSiblings <TVertex, TEdge>(this IBidirectionalGraph <TVertex, TEdge> graph, TVertex vertex1, TVertex vertex2, EdgeDirection edgeDirection) where TEdge : IEdge <TVertex> { var vertex1Parents = graph.GetNeighbours(vertex1, edgeDirection); var vertex2Parents = graph.GetNeighbours(vertex2, edgeDirection); return(vertex1Parents.Intersect(vertex2Parents).Any()); }