FlashGraph-ng
A new frontier in large-scale graph analysis and data mining
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
fm_utils.h
1 #ifndef __FM_UTILS_H__
2 #define __FM_UTILS_H__
3 
4 /*
5  * Copyright 2014 Open Connectome Project (http://openconnecto.me)
6  * Written by Da Zheng (zhengda1936@gmail.com)
7  *
8  * This file is part of FlashMatrix.
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 #include "FGlib.h"
23 
24 #include "sparse_matrix_format.h"
25 #include "data_frame.h"
26 
27 namespace fm
28 {
29 
30 /*
31  * This function creates a row-major matrix from a data frame, which is stored
32  * in a vector of vectors. Each row is stored in a byte vector with the FlashGraph
33  * vertex format (ext_mem_undirected_vertex).
34  *
35  * The input data frame needs to contain at least two vectors: the first
36  * vector contains the row indexes and the second vector contains the column
37  * indexes. If the data frame contains a third vector, the third one contains
38  * the value of non-zero entries.
39  * The order of the rows in the input data frame may be changed.
40  *
41  * This function outputs a vector of vectors that contains the sparse matrix
42  * and a scalar that indicates the number of columns in the sparse matrix.
43  */
44 std::pair<vector_vector::ptr, size_t> create_1d_matrix(data_frame::ptr df);
45 
46 /*
47  * This function creates an edge list stored in the data frame and converts
48  * it into the FlashGraph format stored in memory.
49  */
50 fg::FG_graph::ptr create_fg_graph(const std::string &graph_name,
51  data_frame::ptr df, bool directed);
52 
53 /*
54  * This function creates a 2D-partitioned matrix from a data frame that
55  * contains the locations of the non-zero entries in the matrix.
56  * The matrix and its index are kept in memory.
57  */
58 std::pair<SpM_2d_index::ptr, SpM_2d_storage::ptr> create_2d_matrix(
59  data_frame::ptr df, const block_2d_size &block_size,
60  const scalar_type *entry_type);
61 /*
62  * This function creates a 2D-partitioned matrix from a vector of adjacency
63  * lists. The matrix and its index are kept in memory.
64  * We can't detect the number of columns in the matrix easily, so users
65  * should indicate the number of columns in the matrix.
66  */
67 std::pair<SpM_2d_index::ptr, SpM_2d_storage::ptr> create_2d_matrix(
68  vector_vector::ptr adjs, size_t num_cols,
69  const block_2d_size &block_size, const scalar_type *entry_type);
70 /*
71  * This function creates a 2D-partitioned matrix from a vector of adjacency
72  * lists and stores the matrix and its index in files.
73  * We can't detect the number of columns in the matrix easily, so users
74  * should indicate the number of columns in the matrix.
75  */
76 void export_2d_matrix(vector_vector::ptr adjs, size_t num_cols,
77  const block_2d_size &block_size, const scalar_type *entry_type,
78  const std::string &mat_file, const std::string &mat_idx_file,
79  bool to_safs);
80 
81 /*
82  * A set of functions that change the parameters in the matrix generator.
83  */
84 
85 void set_deduplicate(bool v);
86 void set_remove_self_edge(bool v);
87 };
88 
89 #endif