48 #ifndef OGDF_HYPER_GRAPH_H
49 #define OGDF_HYPER_GRAPH_H
72 int index()
const {
return m_index; }
75 int degree()
const {
return m_numAdj; }
94 int index()
const {
return m_index; }
124 int index()
const {
return m_index; }
162 &NodeElement::m_pNext,
163 &NodeElement::m_index
168 &EdgeElement::m_pNext,
169 &EdgeElement::m_index
174 &AdjElement::m_pNext_nodeAdj,
185 virtual void setSize(
int numElements) = 0;
192 template<
typename T,
typename E>
204 m_pGraph->registerArray(
this);
211 m_pGraph->registerArray(
this);
221 m_pGraph->unregisterArray(
this);
225 const T& operator[](
const E* e)
const
231 T& operator[](
const E* e)
245 virtual void setSize(
int numElements)
263 template<
typename ElementType>
284 int newTableSize(
int minSize)
287 while (res < minSize)
293 void numUsedIndicesChanged(
int numUsedIndices);
310 template<
typename ElementType>
341 m_nodeArrayController.numUsedIndicesChanged(m_nodeAllocator.numUsedIndices());
349 m_edgeArrayController.numUsedIndicesChanged(m_edgeAllocator.numUsedIndices());
357 m_adjArrayController.numUsedIndicesChanged(m_adjAllocator.numUsedIndices());
364 m_nodeAllocator.free(pNode);
370 m_edgeAllocator.free(pEdge);
376 m_adjAllocator.free(pAdj);
422 newAdjElement( pNode1, pEdge );
423 newAdjElement( pNode2, pEdge );
443 AdjElement* pAdj = findAdjElement(pNode, pEdge);
444 if (pAdj) delAdjElement(pAdj);
450 if (!checkIfAlreadyExists)
451 return newAdjElement( pNode, pEdge );
453 AdjElement* pAdj = findAdjElement(pNode, pEdge);
455 pAdj = newAdjElement( pNode, pEdge );
468 AdjElement* pAdj = findAdjElement(pNode, pEdge);
469 if (!removeDuplicates && pAdj)
477 pAdj = findAdjElement(pNode, pEdge);
497 int numberOfNodes()
const;
498 int numberOfEdges()
const;
619 template<
typename ElementType>
629 template<
typename ElementType>
638 template<
typename ElementType>
646 template<
typename ElementType>
650 if (numUsedIndices > m_tableSize)
654 m_tableSize = newTableSize(numUsedIndices);
660 (*it)->setSize(m_tableSize);
718 if ((*it)->theNode() == pNode)
return (*it);
725 if ((*it)->theEdge() == pEdge)
return (*it);
780 template<
typename ListType,
typename ArrayType>
783 for (
typename ListType::iterator it = ListType::begin(array.graph()); it.valid(); it++)
785 outStream << array[*it] << std::endl;
790 template<
typename ListType,
typename ArrayType>
793 for (
typename ListType::iterator it = ListType::begin(array.graph());it.valid(); it++)
795 inStream >> array[(*it)];
800 static std::ostream& operator<<(std::ostream& outStream, HyperGraph::NodeArray<T>& array)
802 writeToStream<HyperGraphTypes::NodeList, HyperGraph::NodeArray<T> >(outStream, array);
807 static std::ostream& operator<<(std::ostream& outStream, HyperGraph::EdgeArray<T>& array)
809 writeToStream<HyperGraphTypes::EdgeList, HyperGraph::EdgeArray<T> >(outStream, array);
814 static std::ostream& operator<<(std::ostream& outStream, HyperGraph::AdjArray<T>& array)
821 outStream << array[(*adj_it)] << std::endl;
831 readFromStream<HyperGraphTypes::NodeList, HyperGraph::NodeArray<T> >(inStream, array);
839 readFromStream<HyperGraphTypes::EdgeList, HyperGraph::EdgeArray<T> >(inStream, array);
852 inStream >> array[(*adj_it)];
869 packed_index[*it] = i++;
878 outStream << packed_index[(*adj_it)->theNode()] << std::endl;
889 inStream >> numNodes;
890 inStream >> numEdges;
893 for (
int i=0; i<numNodes;i++)
896 for (
int i=0; i<numEdges;i++)
901 for (
int j=0; j<numAdj; j++)
904 inStream >> packedNodeIndex;
905 graph.
addNode(pNodes[packedNodeIndex], e);