Diana  0.8.3
CSRGraph.hpp
00001 /* -----------------------------------------------------------------------------
00002  *  Diana process modelling, simulation and analysis software
00003  *  Copyright (c) 2005, Michael Krasnyk
00004  *  All rights reserved.
00005  *
00006  *  This file is a part of Diana process modelling, simulation and analysis software
00007  *
00008  *  Diana is free software; you can redistribute it and/or modify it
00009  *  under the terms of the GNU General Public License as published
00010  *  by the Free Software Foundation (see accompanying file LICENSE)
00011  * -----------------------------------------------------------------------------
00012  *  $Id$
00013  * -----------------------------------------------------------------------------
00014  *  Description:
00015  */
00016 
00017  
00018 #ifndef __CSRGRAPH_H
00019 #define __CSRGRAPH_H
00020 
00021 #include "File.hpp"
00022 #include <vector>
00023 #include <set>
00024 extern "C" 
00025 {
00026     #include "proto.h"
00027 }
00028 
00029 typedef struct 
00030 {
00031    CapeLong lDestination;
00032    CapeLong lEdgeWeight;
00033 } EdgeStruct;
00034 
00035 //definition of graph type (for detailed description see metis documentation)
00036 #define UNWEIGHTED_GRAPH 0 
00037 #define WEIGHTED_EDGES_ONLY 1
00038 #define WEIGHTED_VERTICES_ONLY 2
00039 #define WEIGHTED_EDGES_AND_VERTICES 3
00040 
00050 class CSRGraph
00051 {
00052 private:
00053    CapeString m_szGraphName; // Name of a graph.
00054    int* m_pXadj; 
00055    int* m_pAdjncy;
00056    int* m_pVwgt; 
00057    int* m_pAdjwgt; 
00058    CapeLong m_lEdgesQuantity; 
00059    CapeLong m_lVerticesQuantity; 
00060    int m_nGraphType; 
00061    CapeArrayString EdgesNames; 
00062    CapeArrayString VerticesNames; 
00063 public:
00064    CSRGraph(); 
00065    ~CSRGraph();
00066 
00067    void SetNewValues( std::vector<std::vector<EdgeStruct > > AdjancyVector, 
00068       CapeArrayLong _VerticesWeights, CapeLong EdgesQuantity );
00069 
00071    void SetEdgesNames( const CapeArrayString& _EdgesNames );
00072 
00073    
00075    void SetVerticesNames( const CapeArrayString& _EdgesNames );
00076 
00077 
00089    void WriteToFile( const CapeString& _szFileName );
00090 
00091    
00093    void SetGraphName( const CapeString& _szNewFileName );
00094 
00095 
00099    void Divide( CapeLong lPartsQuantity, CapeArrayLong* Layout );
00100 
00101 
00102    /* Some simple return funcitons  */
00103    CapeLong GetVerticesQuantity();
00104    void GetVerticesNames( CapeArrayString* _VerticesNames );
00105    CapeLong GetEdgesQuantity();
00106    const CapeString& GetGraphName();
00107    void GetAllValues( int* _xadj, int* _adjncy, int* _adjvwgt ); 
00108 };
00109 
00110 #endif