FlashGraph-ng
A new frontier in large-scale graph analysis and data mining
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
fg_utils.h
1 #ifndef __FORMAT_UTILS_H__
2 #define __FORMAT_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 "vertex_index.h"
23 
24 /*
25  * Get the total size of the in-edge lists.
26  */
27 static inline size_t get_in_size(fg::vertex_index::ptr vindex)
28 {
29  assert(vindex->get_graph_header().is_directed_graph());
30  return vindex->get_out_part_loc() - vindex->get_header_size();
31 }
32 
33 /*
34  * Get the offset of the first out-edge list in the graph image.
35  */
36 static inline size_t get_out_off(fg::vertex_index::ptr vindex)
37 {
38  if (vindex->get_graph_header().is_directed_graph())
39  return vindex->get_out_part_loc();
40  else
41  return vindex->get_header_size();
42 }
43 
44 /*
45  * Get the offset of the first in-edge list in the graph image.
46  */
47 static inline size_t get_in_off(fg::vertex_index::ptr vindex)
48 {
49  assert(vindex->get_graph_header().is_directed_graph());
50  return vindex->get_header_size();
51 }
52 
53 /*
54  * Get the total size of the out-edge lists.
55  */
56 size_t get_out_size(fg::vertex_index::ptr vindex);
57 /*
58  * Get the offsets of all out-edge lists in the graph image.
59  */
60 void init_out_offs(fg::vertex_index::ptr vindex, std::vector<off_t> &out_offs);
61 /*
62  * Get the offsets of all in-edge lists in the graph image.
63  */
64 void init_in_offs(fg::vertex_index::ptr vindex, std::vector<off_t> &in_offs);
65 
66 #endif