42 #ifndef BPP_GRAPH_GLOBALGRAPH_H
43 #define BPP_GRAPH_GLOBALGRAPH_H
50 #include "../Clonable.h"
75 typedef std::map<Node, std::pair<std::map<Node, Edge>, std::map<Node, Edge> > >
nodeStructureType;
207 std::vector<Edge>
getEdges_(
const Node& node,
bool outgoing =
true)
const;
224 void fillListOfLeaves_(
const Node& startingNode, std::vector<Node>& foundLeaves,
const Node& originNode,
unsigned int maxRecursions)
const;
238 void nodeToDot_(
const Node& node, std::ostream& out, std::set<std::pair<Node, Node> >& alreadyFigured)
const;
411 template<
typename T,
bool is_const>
414 template<
typename T,
bool is_const>
722 void outputToDot(std::ostream& out,
const std::string& name)
const;
724 template<
class N,
class E,
class GraphImpl>
739 template<
class T,
bool is_const>
747 template<
bool is_const>
752 typedef typename std::conditional<is_const,
753 GlobalGraph::nodeStructureType::const_iterator,
754 GlobalGraph::nodeStructureType::iterator >::type
itType;
759 template<
bool B = is_const>
761 begin_(gg.nodeStructure_.begin()),
762 end_(gg.nodeStructure_.
end()) {}
764 template<
bool B = is_const>
766 begin_(gg.nodeStructure_.begin()),
767 end_(gg.nodeStructure_.end()) {}
769 ~NodesIteratorClass<Graph::ALLGRAPHITER, is_const>(){}
772 bool end()
const {
return it_ == end_; }
784 template<
bool is_const>
788 typedef typename std::conditional<is_const,
789 const std::map<GlobalGraph::Node, GlobalGraph::Edge>&,
790 std::map<GlobalGraph::Node, GlobalGraph::Edge>&>::type
mapType;
794 typedef typename std::conditional<is_const,
795 std::map<GlobalGraph::Node, GlobalGraph::Edge>::const_iterator,
796 std::map<GlobalGraph::Node, GlobalGraph::Edge>::iterator>::type
itType;
803 template<
bool B = is_const>
807 begin_(map_.begin()),
810 template<
bool B = is_const>
811 NeighborIteratorClass<is_const>(std::map<GlobalGraph::Node, GlobalGraph::Edge>& map,
typename std::enable_if<!B>::type* = 0) :
814 begin_(map_.begin()),
818 bool end()
const {
return it_ == end_; }
819 void start() { it_ = begin_; }
828 template<
bool is_const>
848 template<
bool is_const>
872 template<
class T,
bool is_const>
877 template<
bool is_const>
882 typedef typename std::conditional<is_const,
883 GlobalGraph::edgeStructureType::const_iterator,
884 GlobalGraph::edgeStructureType::iterator >::type
itType;
889 template<
bool B = is_const>
891 begin_(gg.edgeStructure_.begin()),
892 end_(gg.edgeStructure_.end()) {}
894 template<
bool B = is_const>
896 begin_(gg.edgeStructure_.begin()),
897 end_(gg.edgeStructure_.end()) {}
899 ~EdgesIteratorClass<Graph::ALLGRAPHITER, is_const>(){}
902 bool end()
const {
return it_ == end_; }
909 template<
bool is_const>
928 template<
bool is_const>
The Clonable interface (allow an object to be cloned).
std::conditional< is_const, GlobalGraph::edgeStructureType::const_iterator, GlobalGraph::edgeStructureType::iterator >::type itType
Graph::EdgeId operator*()
Graph::EdgeId getAnyEdge(Graph::NodeId nodeA, Graph::NodeId nodeB) const
size_t getNumberOfIncomingNeighbors(Graph::NodeId node) const
std::unique_ptr< Graph::NodeIterator > outgoingNeighborNodesIterator(NodeId node)
std::vector< Graph::NodeId > getNeighbors(Graph::NodeId node) const
GlobalGraph & operator=(const GlobalGraph &gg)
std::vector< Graph::EdgeId > getEdges(Graph::NodeId node) const
void fillListOfLeaves_(const Node &startingNode, std::vector< Node > &foundLeaves, const Node &originNode, unsigned int maxRecursions) const
void deleteNode(Graph::NodeId node)
void edgeMustExist_(const Edge &edge, std::string name="") const
bool nodesAreMetOnlyOnce_(const Node &node, std::set< Node > &metNodes, const Node &originNode) const
Graph::EdgeId link(Graph::NodeId nodeA, Graph::NodeId nodeB)
std::unique_ptr< EdgeIterator > allEdgesIterator()
size_t getNumberOfOutgoingNeighbors(Graph::NodeId node) const
std::set< NodeId > getSetOfAllLeaves() const
std::vector< Graph::NodeId > getLeavesFromNode(Graph::NodeId node, unsigned int maxDepth) const
bool containsReciprocalRelations() const
void nodeToDot_(const Node &node, std::ostream &out, std::set< std::pair< Node, Node > > &alreadyFigured) const
edgeStructureType edgeStructure_
Graph::EdgeId getEdge(Graph::NodeId nodeA, Graph::NodeId nodeB) const
Graph::NodeId createNodeFromNode(Graph::NodeId origin)
void switchNodes(Graph::NodeId nodeA, Graph::NodeId nodeB)
void unregisterObserver(GraphObserver *observer)
std::unique_ptr< Graph::NodeIterator > incomingNeighborNodesIterator(NodeId node)
Graph::NodeId createNodeOnEdge(Graph::EdgeId edge)
std::pair< Graph::NodeId, Graph::NodeId > getNodes(Graph::EdgeId edge) const
size_t getNumberOfNodes() const
size_t getNumberOfNeighbors(Graph::NodeId node) const
Graph::NodeId getRoot() const
std::unique_ptr< EdgeIterator > incomingEdgesIterator(NodeId node)
std::vector< Edge > getEdges_(const Node &node, bool outgoing=true) const
std::vector< Graph::NodeId > getAllNodes() const
GlobalGraph * clone() const
Create a copy of this object and send a pointer to it.
std::vector< Node > getNeighbors_(const Node &node, bool outgoing=true) const
std::map< Node, std::pair< std::map< Node, Edge >, std::map< Node, Edge > > > nodeStructureType
Graph::NodeId createNodeFromEdge(Graph::NodeId origin)
nodeStructureType nodeStructure_
std::vector< Graph::EdgeId > unlink(Graph::NodeId nodeA, Graph::NodeId nodeB)
void linkInEdgeStructure_(const Node &nodeA, const Node &nodeB, const Edge &edge)
std::set< GraphObserver * > observers_
bool isLeaf(Graph::NodeId node) const
size_t getNumberOfEdges() const
void linkInNodeStructure_(const Node &nodeA, const Node &nodeB, const Edge &edge)
std::vector< Graph::NodeId > getAllInnerNodes() const
std::unique_ptr< Graph::NodeIterator > allNodesIterator()
std::vector< Graph::NodeId > getIncomingNeighbors(Graph::NodeId node) const
Graph::NodeId getTop(Graph::EdgeId edge) const
Edge unlinkInNodeStructure_(const Node &nodeA, const Node &nodeB)
void unlinkInEdgeStructure_(const Edge &edge)
std::vector< Graph::EdgeId > getIncomingEdges(Graph::NodeId node) const
void isolate_(Node &node)
std::unique_ptr< EdgeIterator > outgoingEdgesIterator(NodeId node)
void registerObserver(GraphObserver *observer)
virtual void topologyHasChanged_() const
std::vector< Graph::EdgeId > getOutgoingEdges(Graph::NodeId node) const
void outputToDot(std::ostream &out, const std::string &name) const
std::map< Edge, std::pair< Node, Node > > edgeStructureType
size_t getDegree(Graph::NodeId node) const
std::vector< Graph::EdgeId > getAllEdges() const
std::vector< Graph::NodeId > getAllLeaves() const
void notifyDeletedNodes(const std::vector< Graph::NodeId > &nodesToDelete) const
Graph::NodeId createNode()
GlobalGraph(bool directed=false)
void nodeMustExist_(const Node &node, std::string name="") const
Graph::NodeId getBottom(Graph::EdgeId edge) const
std::vector< Graph::NodeId > getOutgoingNeighbors(Graph::NodeId node) const
void setRoot(Graph::NodeId newRoot)
void notifyDeletedEdges(const std::vector< Graph::EdgeId > &edgesToDelete) const
Defines a Graph Observer. It is a template which follows (subscribed to) a Graph. The graph and the g...
virtual bool end() const =0
Abstract class for neighbor iterators.
std::conditional< is_const, std::map< GlobalGraph::Node, GlobalGraph::Edge >::const_iterator, std::map< GlobalGraph::Node, GlobalGraph::Edge >::iterator >::type itType
std::conditional< is_const, const std::map< GlobalGraph::Node, GlobalGraph::Edge > &, std::map< GlobalGraph::Node, GlobalGraph::Edge > & >::type mapType
Graph::NodeId operator*()
std::conditional< is_const, GlobalGraph::nodeStructureType::const_iterator, GlobalGraph::nodeStructureType::iterator >::type itType
Graph::NodeId operator*()
std::vector< T > operator*(const std::vector< T > &v1, const std::vector< T > &v2)