5 #ifndef BPP_GRAPH_GLOBALGRAPH_H 6 #define BPP_GRAPH_GLOBALGRAPH_H 13 #include "../Clonable.h" 38 typedef std::map<Node, std::pair<std::map<Node, Edge>, std::map<Node, Edge>>>
nodeStructureType;
146 void nodeMustExist_(
const Node& node, std::string name =
"")
const;
153 void edgeMustExist_(
const Edge& edge, std::string name =
"")
const;
162 std::vector<Node>
getNeighbors_(
const Node& node,
bool outgoing =
true)
const;
170 std::vector<Edge>
getEdges_(
const Node& node,
bool outgoing =
true)
const;
187 void fillListOfLeaves_(
const Node& startingNode, std::vector<Node>& foundLeaves,
const Node& originNode,
unsigned int maxRecursions)
const;
195 bool nodesAreMetOnlyOnce_(
const Node& node, std::set<Node>& metNodes,
const Node& originNode)
const;
201 void nodeToDot_(
const Node& node, std::ostream& out, std::set<std::pair<Node, Node>>& alreadyFigured)
const;
374 template<
typename T,
bool is_const>
377 template<
typename T,
bool is_const>
685 void outputToDot(std::ostream& out,
const std::string& name)
const;
687 template<
class N,
class E,
class GraphImpl>
702 template<
class T,
bool is_const>
710 template<
bool is_const>
715 typedef typename std::conditional<is_const,
716 GlobalGraph::nodeStructureType::const_iterator,
717 GlobalGraph::nodeStructureType::iterator >::type
itType;
722 template<
bool B = is_const>
724 begin_(gg.nodeStructure_.begin()),
725 end_(gg.nodeStructure_.
end()) {}
727 template<
bool B = is_const>
729 begin_(gg.nodeStructure_.begin()),
730 end_(gg.nodeStructure_.
end()) {}
735 bool end()
const {
return it_ == end_; }
747 template<
bool is_const>
751 typedef typename std::conditional<is_const,
752 const std::map<GlobalGraph::Node, GlobalGraph::Edge>&,
753 std::map<GlobalGraph::Node, GlobalGraph::Edge>&>::type
mapType;
757 typedef typename std::conditional<is_const,
758 std::map<GlobalGraph::Node, GlobalGraph::Edge>::const_iterator,
759 std::map<GlobalGraph::Node, GlobalGraph::Edge>::iterator>::type
itType;
766 template<
bool B = is_const>
770 begin_(map_.begin()),
773 template<
bool B = is_const>
777 begin_(map_.begin()),
781 bool end()
const {
return it_ == end_; }
791 template<
bool is_const>
811 template<
bool is_const>
835 template<
class T,
bool is_const>
840 template<
bool is_const>
845 typedef typename std::conditional<is_const,
846 GlobalGraph::edgeStructureType::const_iterator,
847 GlobalGraph::edgeStructureType::iterator >::type
itType;
852 template<
bool B = is_const>
854 begin_(gg.edgeStructure_.begin()),
855 end_(gg.edgeStructure_.
end()) {}
857 template<
bool B = is_const>
859 begin_(gg.edgeStructure_.begin()),
860 end_(gg.edgeStructure_.
end()) {}
865 bool end()
const {
return it_ == end_; }
872 template<
bool is_const>
891 template<
bool is_const>
910 #endif // BPP_GRAPH_GLOBALGRAPH_H virtual void topologyHasChanged_() const
std::vector< Graph::EdgeId > getOutgoingEdges(Graph::NodeId node) const
size_t getNumberOfEdges() const
std::unique_ptr< EdgeIterator > allEdgesIterator()
Abstract class for neighbor iterators.
size_t getNumberOfOutgoingNeighbors(Graph::NodeId node) const
void unregisterObserver(GraphObserver *observer)
virtual bool end() const =0
void notifyDeletedEdges(const std::vector< Graph::EdgeId > &edgesToDelete) const
Graph::NodeId getBottom(Graph::EdgeId edge) const
void switchNodes(Graph::NodeId nodeA, Graph::NodeId nodeB)
void outputToDot(std::ostream &out, const std::string &name) const
void edgeMustExist_(const Edge &edge, std::string name="") const
Graph::EdgeId getEdge(Graph::NodeId nodeA, Graph::NodeId nodeB) const
std::conditional< is_const, const std::map< GlobalGraph::Node, GlobalGraph::Edge > &, std::map< GlobalGraph::Node, GlobalGraph::Edge > & >::type mapType
Graph::EdgeId getAnyEdge(Graph::NodeId nodeA, Graph::NodeId nodeB) const
std::map< Edge, std::pair< Node, Node > > edgeStructureType
void deleteNode(Graph::NodeId node)
Graph::NodeId operator*()
Graph::NodeId operator*()
GlobalGraph * clone() const
Create a copy of this object and send a pointer to it.
std::vector< Graph::NodeId > getIncomingNeighbors(Graph::NodeId node) const
std::vector< Graph::EdgeId > getIncomingEdges(Graph::NodeId node) const
std::conditional< is_const, std::map< GlobalGraph::Node, GlobalGraph::Edge >::const_iterator, std::map< GlobalGraph::Node, GlobalGraph::Edge >::iterator >::type itType
Graph::NodeId createNodeOnEdge(Graph::EdgeId edge)
void nodeMustExist_(const Node &node, std::string name="") const
bool containsReciprocalRelations() const
Graph::NodeId createNode()
bool nodesAreMetOnlyOnce_(const Node &node, std::set< Node > &metNodes, const Node &originNode) const
std::vector< Node > getNeighbors_(const Node &node, bool outgoing=true) const
std::set< GraphObserver * > observers_
void setRoot(Graph::NodeId newRoot)
std::vector< Graph::NodeId > getAllLeaves() const
Edge unlinkInNodeStructure_(const Node &nodeA, const Node &nodeB)
std::conditional< is_const, GlobalGraph::nodeStructureType::const_iterator, GlobalGraph::nodeStructureType::iterator >::type itType
void linkInEdgeStructure_(const Node &nodeA, const Node &nodeB, const Edge &edge)
std::vector< Graph::NodeId > getLeavesFromNode(Graph::NodeId node, unsigned int maxDepth) const
std::vector< Edge > getEdges_(const Node &node, bool outgoing=true) const
Graph::NodeId createNodeFromEdge(Graph::NodeId origin)
Graph::EdgeId link(Graph::NodeId nodeA, Graph::NodeId nodeB)
virtual bool end() const =0
std::unique_ptr< Graph::NodeIterator > incomingNeighborNodesIterator(NodeId node)
GlobalGraph(bool directed=false)
Graph::EdgeId operator*()
std::map< Node, std::pair< std::map< Node, Edge >, std::map< Node, Edge > > > nodeStructureType
size_t getNumberOfNodes() const
Graph::NodeId getTop(Graph::EdgeId edge) const
size_t getNumberOfIncomingNeighbors(Graph::NodeId node) const
void unlinkInEdgeStructure_(const Edge &edge)
std::unique_ptr< Graph::NodeIterator > allNodesIterator()
GlobalGraph & operator=(const GlobalGraph &gg)
std::unique_ptr< EdgeIterator > outgoingEdgesIterator(NodeId node)
bool isLeaf(Graph::NodeId node) const
std::vector< Graph::EdgeId > unlink(Graph::NodeId nodeA, Graph::NodeId nodeB)
Graph::NodeId operator*()
void fillListOfLeaves_(const Node &startingNode, std::vector< Node > &foundLeaves, const Node &originNode, unsigned int maxRecursions) const
std::vector< Graph::NodeId > getOutgoingNeighbors(Graph::NodeId node) const
std::unique_ptr< Graph::NodeIterator > outgoingNeighborNodesIterator(NodeId node)
The Clonable interface (allow an object to be cloned).
void linkInNodeStructure_(const Node &nodeA, const Node &nodeB, const Edge &edge)
std::unique_ptr< EdgeIterator > incomingEdgesIterator(NodeId node)
std::vector< Graph::NodeId > getAllInnerNodes() const
Graph::EdgeId operator*()
std::vector< Graph::NodeId > getNeighbors(Graph::NodeId node) const
std::vector< Graph::EdgeId > getAllEdges() const
nodeStructureType nodeStructure_
Graph::NodeId createNodeFromNode(Graph::NodeId origin)
size_t getDegree(Graph::NodeId node) const
void registerObserver(GraphObserver *observer)
Defines a Graph Observer. It is a template which follows (subscribed to) a Graph. The graph and the g...
void notifyDeletedNodes(const std::vector< Graph::NodeId > &nodesToDelete) const
std::vector< Graph::NodeId > getAllNodes() const
std::set< NodeId > getSetOfAllLeaves() const
size_t getNumberOfNeighbors(Graph::NodeId node) const
std::pair< Graph::NodeId, Graph::NodeId > getNodes(Graph::EdgeId edge) const
void nodeToDot_(const Node &node, std::ostream &out, std::set< std::pair< Node, Node >> &alreadyFigured) const
std::conditional< is_const, GlobalGraph::edgeStructureType::const_iterator, GlobalGraph::edgeStructureType::iterator >::type itType
Graph::EdgeId operator*()
edgeStructureType edgeStructure_
Graph::NodeId getRoot() const
std::vector< Graph::EdgeId > getEdges(Graph::NodeId node) const
void isolate_(Node &node)