/************************************************************************************* Copyright (C) <2009> <Melih Sozdinler> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Copyright (C) <2009> <Melih Sozdinler> This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. **************************************************************************************/ #include "declerations.h" /*****************************************************************************************************/ template <class T> void addNewHyperEdge(GRAPH<T,T> &G, list<node> &V, edge_array<list<node>> &HyperEdges ){ edge e; e = G.new_edge(); HyperEdges.init( G ); HyperEdges[e] = V; } /*****************************************************************************************************/ template <class T> node addNewHyperNode(GRAPH<T,T> &G, list<node> &V, edge_array<list<node>> &HyperEdges, list<edge> edgeList ){ node n = G.new_node(); V.append( n ); list_item it; forall_items( it, edgeList ){ HyperEdges[ edgeList[ it ] ].append( n ); } return n; } /*****************************************************************************************************/ template <class T> void deleteHyperEdge(GRAPH<T,T> &G, edge_array<list<node>> &HyperEdges, edge e ){ G.del_edge( e ); HyperEdges.init( G ); } /*****************************************************************************************************/ template <class T> void deleteHyperNode(GRAPH<T,T> &G, node n, list<node> &V, edge_array<list<node>> &HyperEdges ){ G.del_node( n ); list<node> temp; list_item it; edge e; forall_items( it, V ){ if( V[ it ] == n ) V.del_item( it ); } forall_edges( e, G ){ temp = HyperEdges[ e ]; forall_items( it, temp ){ if( temp[ it ] == n ){ temp.del_item( it ); } } HyperEdges[ e ] = temp; } } /*****************************************************************************************************/ template <class T> void clearHyperGraph(GRAPH<T,T> &G, list<node> &V, edge_array<list<node>> &HyperEdges){ G.clear(); V.clear(); HyperEdges.init( G ); } /*****************************************************************************************************/ template <class T> void copyHyperGraph(GRAPH<T,T> &G1, list<node> &V1, edge_array<list<node>> &HyperEdges1, GRAPH<T,T> &G2, list<node> &V2, edge_array<list<node>> &HyperEdges2 ){ G2 = G1;
V2 = V1; HyperEdges2 = HyperEdges1; } /*****************************************************************************************************/ template <class T> void createHyperGraph(GRAPH<T,T> &G, list<node> &V, edge_array<list<node>> &HyperEdges){ // Graph is created } /*****************************************************************************************************/ template <class T> void findHyperCycle(); /* TO BE DONE */ /*****************************************************************************************************/ template <class T> void findIntersectedNodes(); /* TO BE DONE */ /*****************************************************************************************************/ template <class T> list<edge> findHyperEdges(GRAPH<T,T> &G, node n, edge_array<list<node>> &HyperEdges ){ edge e; list_item it; list<node> temp; list<edge> elist; forall_edges( e, G ){ temp = HyperEdges[ e ]; forall_items( it, temp ){ if( temp[ it ] == n ) elist.append( e ); } } return elist; } /*****************************************************************************************************/ list<node> getNodes( edge e, edge_array<list<node>> &HyperEdges ){ return HyperEdges[ e ]; } /*****************************************************************************************************/