/// <summary> /// Construct a filtered graph with an edge and a vertex predicate. /// </summary> /// <param name="g">graph to filter</param> /// <param name="edgePredicate">edge predicate</param> /// <param name="vertexPredicate">vertex predicate</param> /// <exception cref="ArgumentNullException"> /// g, edgePredicate or vertexPredicate are null /// </exception> public FilteredBidirectionalGraph( IBidirectionalGraph g, IEdgePredicate edgePredicate, IVertexPredicate vertexPredicate) : base(g,edgePredicate,vertexPredicate) { }
/// <summary> /// Construct a filtered graph with an edge and a vertex predicate. /// </summary> /// <param name="g">graph to filter</param> /// <param name="edgePredicate">edge predicate</param> /// <param name="vertexPredicate">vertex predicate</param> /// <exception cref="ArgumentNullException"> /// g, edgePredicate or vertexPredicate are null /// </exception> public FilteredVertexListGraph( IVertexListGraph g, IEdgePredicate edgePredicate, IVertexPredicate vertexPredicate) : base(g, edgePredicate, vertexPredicate) { }
/// <summary> /// Construct a graph that filters in-edges /// </summary> /// <param name="g">graph to filter</param> /// <param name="vertexPredicate">vertex predicate</param> /// <exception cref="ArgumentNullException"> /// g or vertexPredicate is null /// </exception> public FilteredVertexListGraph( IVertexListGraph g, IVertexPredicate vertexPredicate ) : base(g,new KeepAllEdgesPredicate(), vertexPredicate) { }
/// <summary> /// Construct a graph that filters edges /// </summary> /// <param name="g">graph to filter</param> /// <param name="edgePredicate">edge predicate</param> /// <param name="vertexPredicate">vertex predicate</param> /// <exception cref="ArgumentNullException"> /// g or edgePredicate or vertexPredicate is null /// </exception> public FilteredEdgeListGraph( IEdgeListGraph g, IEdgePredicate edgePredicate, IVertexPredicate vertexPredicate ) : base(g,edgePredicate,vertexPredicate) {}
/// <summary> /// Construct a filtered graph with an edge and a vertex predicate. /// </summary> /// <param name="g">graph to filter</param> /// <param name="edgePredicate">edge predicate</param> /// <param name="vertexPredicate">vertex predicate</param> /// <exception cref="ArgumentNullException"> /// g, edgePredicate or vertexPredicate are null /// </exception> public FilteredBidirectionalGraph( IBidirectionalGraph g, IEdgePredicate edgePredicate, IVertexPredicate vertexPredicate) : base(g, edgePredicate, vertexPredicate) { }
/// <summary> /// Construct a filtered graph with an edge and a vertex predicate. /// </summary> /// <param name="g">graph to filter</param> /// <param name="edgePredicate">edge predicate</param> /// <param name="vertexPredicate">vertex predicate</param> /// <exception cref="ArgumentNullException"> /// g, edgePredicate or vertexPredicate are null /// </exception> public FilteredIncidenceGraph( IIncidenceGraph g, IEdgePredicate edgePredicate, IVertexPredicate vertexPredicate) : base(g, edgePredicate, vertexPredicate) { }
/// <summary> /// Construct a filtered graph with an edge and a vertex predicate. /// </summary> /// <param name="g">graph to filter</param> /// <param name="edgePredicate">edge predicate</param> /// <param name="vertexPredicate">vertex predicate</param> /// <exception cref="ArgumentNullException"> /// g, edgePredicate or vertexPredicate are null /// </exception> public FilteredIncidenceGraph( IIncidenceGraph g, IEdgePredicate edgePredicate, IVertexPredicate vertexPredicate) : base(g,edgePredicate,vertexPredicate) { }
/// <summary> /// Construct a graph that filters in-edges /// </summary> /// <param name="g">graph to filter</param> /// <param name="vertexPredicate">vertex predicate</param> /// <exception cref="ArgumentNullException"> /// g or vertexPredicate is null /// </exception> public FilteredVertexListGraph( IVertexListGraph g, IVertexPredicate vertexPredicate ) : base(g, new KeepAllEdgesPredicate(), vertexPredicate) { }
/// <summary> /// Constructs a new <see cref="NotVertexPredicate"/>. /// </summary> /// <param name="predicate">predicate to invert</param> public NotVertexPredicate(IVertexPredicate predicate) { if (predicate == null) { throw new ArgumentNullException("predicate"); } this.predicate = predicate; }
/// <summary> /// Construct a graph that filters edges and vertices /// </summary> /// <param name="g">graph to filter</param> /// <param name="edgePredicate">edge predicate</param> /// <param name="vertexPredicate"></param> /// <exception cref="ArgumentNullException"> /// g or edgePredicate is null /// </exception> public FilteredVertexAndEdgeListGraph( IVertexAndEdgeListGraph g, IEdgePredicate edgePredicate, IVertexPredicate vertexPredicate ) : base(g, edgePredicate, vertexPredicate) { this.filteredEdgeList = new FilteredEdgeListGraph(g, edgePredicate); }
/// <summary> /// Construct a graph that filters edges and out-edges /// </summary> /// <param name="g">graph to filter</param> /// <param name="edgePredicate">edge predicate</param> /// <param name="vertexPredicate"></param> /// <exception cref="ArgumentNullException"> /// g or edgePredicate is null /// </exception> public FilteredEdgeListAndIncidenceGraph( IEdgeListAndIncidenceGraph g, IEdgePredicate edgePredicate, IVertexPredicate vertexPredicate ) : base(g, edgePredicate, vertexPredicate) { m_FilteredIncidenceGraph = new FilteredIncidenceGraph(g, edgePredicate, vertexPredicate); }
/// <summary> /// Returns the collection of vertices that matches the predicate /// </summary> /// <param name="vp">vertex predicate</param> /// <returns>enumerable colleciton of vertices that matches the /// criteron</returns> /// <exception cref="ArgumentNullException">vp is null</exception> public IVertexEnumerable SelectVertices(IVertexPredicate vp) { if (vp == null) { throw new ArgumentNullException("vertex predicate"); } return(new FilteredVertexEnumerable(Vertices, vp)); }
/// <summary> /// Construct a filtered graph with an edge and a vertex predicate. /// </summary> /// <param name="g">graph to filter</param> /// <param name="edgePredicate">edge predicate</param> /// <param name="vertexPredicate">vertex predicate</param> /// <exception cref="ArgumentNullException"> /// g, edgePredicate or vertexPredicate are null /// </exception> public FilteredGraph( IGraph g, IEdgePredicate edgePredicate, IVertexPredicate vertexPredicate) { Graph = g; EdgePredicate = edgePredicate; VertexPredicate = vertexPredicate; }
/// <summary> /// Construct a graph that filters edges and vertices /// </summary> /// <param name="g">graph to filter</param> /// <param name="edgePredicate">edge predicate</param> /// <param name="vertexPredicate"></param> /// <exception cref="ArgumentNullException"> /// g or edgePredicate is null /// </exception> public FilteredVertexAndEdgeListGraph( IVertexAndEdgeListGraph g, IEdgePredicate edgePredicate, IVertexPredicate vertexPredicate ) : base(g,edgePredicate,vertexPredicate) { this.filteredEdgeList = new FilteredEdgeListGraph(g,edgePredicate); }
/// <summary> /// Construct a graph that filters edges and out-edges /// </summary> /// <param name="g">graph to filter</param> /// <param name="edgePredicate">edge predicate</param> /// <param name="vertexPredicate"></param> /// <exception cref="ArgumentNullException"> /// g or edgePredicate is null /// </exception> public FilteredEdgeListAndIncidenceGraph( IEdgeListAndIncidenceGraph g, IEdgePredicate edgePredicate, IVertexPredicate vertexPredicate ) : base(g,edgePredicate,vertexPredicate) { m_FilteredIncidenceGraph = new FilteredIncidenceGraph(g,edgePredicate,vertexPredicate); }
/// <summary> /// Construct a new predicate. /// </summary> /// <param name="ep">the edge predicate</param> /// <param name="vp">the source vertex predicate</param> /// <exception cref="ArgumentNullException">ep or vp is null</exception> public InEdgePredicate(IEdgePredicate ep, IVertexPredicate vp) { if (ep == null) throw new ArgumentNullException("Edge predicate"); if (vp == null) throw new ArgumentNullException("Vertex predicate"); m_EdgePredicate = ep; m_VertexPredicate = vp; }
/// <summary> /// Default constructor /// </summary> /// <param name="ec">base collection</param> /// <param name="ep">predicate</param> /// <exception cref="ArgumentNullException">ec or ep null</exception> public FilteredVertexEnumerable(VertexCollection ec, IVertexPredicate ep) { if (ec == null) throw new ArgumentNullException("Vertex collection"); if (ep == null) throw new ArgumentNullException("Vertex predicate"); m_VertexCollection = ec; m_VertexPredicate = ep; }
/// <summary> /// Create an adjacency filtered graph /// </summary> /// <param name="g">graph to filter</param> /// <param name="vp">vertex predicate</param> public FilteredAdjacencyGraph( IAdjacencyGraph g, IVertexPredicate vp ) { if (g==null) throw new ArgumentNullException("g is null"); m_AdjacencyGraph = g; VertexPredicate = vp; }
/// <summary> /// Create an adjacency filtered graph /// </summary> /// <param name="g">graph to filter</param> /// <param name="vp">vertex predicate</param> public FilteredAdjacencyGraph( IAdjacencyGraph g, IVertexPredicate vp ) { if (g == null) { throw new ArgumentNullException("g is null"); } m_AdjacencyGraph = g; VertexPredicate = vp; }
/// <summary> /// Returns the first vertex that matches the predicate /// </summary> /// <param name="vp">vertex predicate</param> /// <returns>null if not found, otherwize the first vertex that /// matches the predicate.</returns> /// <exception cref="ArgumentNullException">vp is null</exception> public IVertex SelectSingleVertex(IVertexPredicate vp) { if (vp == null) { throw new ArgumentNullException("vertex predicate"); } foreach (IVertex v in SelectVertices(vp)) { return(v); } return(null); }
/// <summary> /// /// </summary> /// <param name="ep"></param> /// <param name="vp"></param> public InEdgePredicate(IEdgePredicate ep, IVertexPredicate vp) { if (ep == null) { throw new ArgumentNullException("Edge predicate"); } if (vp == null) { throw new ArgumentNullException("Vertex predicate"); } m_EdgePredicate = ep; m_VertexPredicate = vp; }
/// <summary> /// Default constructor /// </summary> /// <param name="ec">base collection</param> /// <param name="ep">predicate</param> /// <exception cref="ArgumentNullException">ec or ep null</exception> public FilteredVertexEnumerable(VertexCollection ec, IVertexPredicate ep) { if (ec == null) { throw new ArgumentNullException("Vertex collection"); } if (ep == null) { throw new ArgumentNullException("Vertex predicate"); } m_VertexCollection = ec; m_VertexPredicate = ep; }
/// <summary> /// Returns the first vertex of the enumerable that matches the predicate. /// </summary> /// <param name="vertices">enumerable collection of <see cref="IVertex"/></param> /// <param name="pred">vertex predicate</param> /// <returns>first vertex if any, otherwise a null reference</returns> public static IVertex FirstVertexIf(IVertexEnumerable vertices, IVertexPredicate pred) { if (vertices == null) { throw new ArgumentNullException("vertices"); } if (pred == null) { throw new ArgumentNullException("pred"); } IVertexEnumerator en = vertices.GetEnumerator(); while (en.MoveNext()) { if (pred.Test(en.Current)) { return(en.Current); } } return(null); }
/// <summary> /// /// </summary> /// <param name="vp"></param> /// <returns></returns> public IVertexEnumerable SelectVertices(IVertexPredicate vp) { return(Wrapped.SelectVertices(vp)); }
/// <summary> /// /// </summary> /// <param name="vp"></param> /// <returns></returns> public IVertex SelectSingleVertex(IVertexPredicate vp) { return(Wrapped.SelectSingleVertex(vp)); }
/// <summary> /// Creates a predicate that check the edge and the edge source /// </summary> /// <param name="ep">edge predicate to apply to the edge</param> /// <param name="vp">vertex predicate to apply to the edge source</param> /// <returns>in-edge predicate</returns> public static InEdgePredicate InEdge(IEdgePredicate ep, IVertexPredicate vp) { return new InEdgePredicate(ep,vp); }
/// <summary> /// Creates a predicate that check the edge and the edge target /// </summary> /// <param name="ep">edge predicate to apply to the edge</param> /// <param name="vp">vertex predicate to apply to the edge target</param> /// <returns>out-edge predicate</returns> public static OutEdgePredicate OutEdge(IEdgePredicate ep, IVertexPredicate vp) { return new OutEdgePredicate(ep,vp); }
/// <summary> /// Negates a predicate /// </summary> /// <param name="predicate"></param> /// <returns></returns> public static NotVertexPredicate Not(IVertexPredicate predicate) { return new NotVertexPredicate(predicate); }
/// <summary> /// Creates a predicate that check the edge and the edge source /// </summary> /// <param name="ep">edge predicate to apply to the edge</param> /// <param name="vp">vertex predicate to apply to the edge source</param> /// <returns>in-edge predicate</returns> public static InEdgePredicate InEdge(IEdgePredicate ep, IVertexPredicate vp) { return(new InEdgePredicate(ep, vp)); }
/// <summary> /// Constructor /// </summary> /// <param name="e">Base enumerator</param> /// <param name="p">predicate</param> public Enumerator(VertexCollection.Enumerator e, IVertexPredicate p) { m_Enumerator = e; m_Predicate = p; }
/// <summary> /// /// </summary> /// <param name="vp"></param> /// <returns></returns> public IVertexEnumerable SelectVertices(IVertexPredicate vp) { return Wrapped.SelectVertices(vp); }
/// <summary> /// /// </summary> /// <param name="vp"></param> /// <returns></returns> public IVertex SelectSingleVertex(IVertexPredicate vp) { return Wrapped.SelectSingleVertex(vp); }
public IVertex SelectSingleVertex(IVertexPredicate vp) { if (vp == null) { throw new ArgumentNullException("vertex predicate"); } IVertexEnumerator enumerator = this.SelectVertices(vp).GetEnumerator(); while (enumerator.MoveNext()) { return enumerator.get_Current(); } return null; }
/// <summary> /// Creates a predicate that check the edge and the edge target /// </summary> /// <param name="ep">edge predicate to apply to the edge</param> /// <param name="vp">vertex predicate to apply to the edge target</param> /// <returns>out-edge predicate</returns> public static OutEdgePredicate OutEdge(IEdgePredicate ep, IVertexPredicate vp) { return(new OutEdgePredicate(ep, vp)); }
/// <summary> /// Constructor /// </summary> /// <param name="e">Base enumerator</param> /// <param name="p">predicate</param> public Enumerator(IVertexEnumerator e, IVertexPredicate p) { m_Enumerator = e; m_Predicate = p; }
IVertex IFilteredVertexListGraph.SelectSingleVertex(IVertexPredicate vp) { return this.SelectSingleVertex(vp); }
/// <summary> /// Returns the first vertex that matches the predicate /// </summary> /// <param name="vp">vertex predicate</param> /// <returns>null if not found, otherwize the first vertex that /// matches the predicate.</returns> /// <exception cref="ArgumentNullException">vp is null</exception> public IVertex SelectSingleVertex(IVertexPredicate vp) { if (vp == null) throw new ArgumentNullException("vertex predicate"); foreach(IVertex v in SelectVertices(vp)) return v; return null; }
/// <summary> /// Constructs a new <see cref="NotVertexPredicate"/>. /// </summary> /// <param name="predicate">predicate to invert</param> public NotVertexPredicate(IVertexPredicate predicate) { if (predicate==null) throw new ArgumentNullException("predicate"); this.predicate = predicate; }
/// <summary> /// Returns the first vertex of the enumerable that matches the predicate. /// </summary> /// <param name="vertices">enumerable collection of <see cref="IVertex"/></param> /// <param name="pred">vertex predicate</param> /// <returns>first vertex if any, otherwise a null reference</returns> public static IVertex FirstVertexIf(IVertexEnumerable vertices, IVertexPredicate pred) { if (vertices==null) throw new ArgumentNullException("vertices"); if (pred==null) throw new ArgumentNullException("pred"); IVertexEnumerator en = vertices.GetEnumerator(); while(en.MoveNext()) { if (pred.Test(en.Current)) return en.Current; } return null; }
/// <summary> /// Returns the collection of vertices that matches the predicate /// </summary> /// <param name="vp">vertex predicate</param> /// <returns>enumerable colleciton of vertices that matches the /// criteron</returns> /// <exception cref="ArgumentNullException">vp is null</exception> public IVertexEnumerable SelectVertices(IVertexPredicate vp) { if (vp == null) throw new ArgumentNullException("vertex predicate"); return new FilteredVertexEnumerable(Vertices,vp); }
/// <summary> /// Negates a predicate /// </summary> /// <param name="predicate"></param> /// <returns></returns> public static NotVertexPredicate Not(IVertexPredicate predicate) { return(new NotVertexPredicate(predicate)); }