Revision 162e1bda custompackages/graph-parser/src/utility.cpp

View differences:

custompackages/graph-parser/src/utility.cpp
87 87
        }
88 88
    }
89 89

  
90
    void print_edge(const Graph& g, const Edge& e) {
91
        string s = g[boost::source(e, g)].id;
92
        string t = g[boost::target(e, g)].id;
93

  
94
        printf("edge (%s, %s)", s.c_str(), t.c_str());
95
    }
96

  
90 97
    void print_v_index_std_map(const Graph& g, const VertexIndexStdMap& v_index_std_map) {
91 98
        std::list<std::string> outputs;
92 99

  
......
129 136
        cout << "Edge Index Map:\n";
130 137
        cout << format("[\n  " << (auto_ % "\n  ") << "\n]\n", outputs);
131 138
    }
132
}
139

  
140
    void write_betweenness_centrality(Graph const& g, std::vector<double> v_centrality_vec, string file_path) {
141
        cout << "XXX Writing to File";
142
        // string filepath = "../output/boost_" + fileSuffix + ".csv";
143
        ofstream out_file(file_path.c_str());
144

  
145
        Viter vi, ve;
146
        size_t i = 0;
147
        if (out_file.is_open()) {
148
            for (boost::tie(vi, ve) = boost::vertices(g); vi != ve; ++vi) {
149
                out_file << g[*vi].id << ", " << v_centrality_vec.at(i) << endl;
150
                ++i;
151
            }
152
        }
153
        out_file.close();
154

  
155
        cout << "Done Writing BC score to file " << file_path << endl;
156
    }
157
}
158

  
159
// GENERAL HELPERS
160
namespace helper {
161
    string get_file_name(const string& s) {
162
       char sep = '/';
163

  
164
    #ifdef _WIN32
165
       sep = '\\';
166
    #endif
167

  
168
       size_t i = s.rfind(sep, s.length());
169
       if (i != string::npos) {
170
          return(s.substr(i+1, s.length() - i));
171
       }
172

  
173
       return("");
174
    }
175
}

Also available in: Unified diff