creators.cc 2.45 KB
Newer Older
sangwzh's avatar
sangwzh committed
1
// !!! This is a file automatically generated by hipify!!!
2
/**
3
 *  Copyright (c) 2020 by Contributors
4
5
 * @file graph/creators.cc
 * @brief Functions for constructing graphs.
6
 */
sangwzh's avatar
sangwzh committed
7
#include "heterograph.h"
8
9
10
11
12
13
using namespace dgl::runtime;

namespace dgl {

// creator implementation
HeteroGraphPtr CreateHeteroGraph(
14
    GraphPtr meta_graph, const std::vector<HeteroGraphPtr>& rel_graphs,
15
    const std::vector<int64_t>& num_nodes_per_type) {
16
17
  return HeteroGraphPtr(
      new HeteroGraph(meta_graph, rel_graphs, num_nodes_per_type));
18
19
20
}

HeteroGraphPtr CreateFromCOO(
21
22
    int64_t num_vtypes, int64_t num_src, int64_t num_dst, IdArray row,
    IdArray col, bool row_sorted, bool col_sorted, dgl_format_code_t formats) {
23
  auto unit_g = UnitGraph::CreateFromCOO(
24
      num_vtypes, num_src, num_dst, row, col, row_sorted, col_sorted, formats);
25
26
27
  return HeteroGraphPtr(new HeteroGraph(unit_g->meta_graph(), {unit_g}));
}

28
HeteroGraphPtr CreateFromCOO(
29
    int64_t num_vtypes, const aten::COOMatrix& mat, dgl_format_code_t formats) {
30
  auto unit_g = UnitGraph::CreateFromCOO(num_vtypes, mat, formats);
31
32
33
  return HeteroGraphPtr(new HeteroGraph(unit_g->meta_graph(), {unit_g}));
}

34
HeteroGraphPtr CreateFromCSR(
35
36
    int64_t num_vtypes, int64_t num_src, int64_t num_dst, IdArray indptr,
    IdArray indices, IdArray edge_ids, dgl_format_code_t formats) {
37
  auto unit_g = UnitGraph::CreateFromCSR(
38
      num_vtypes, num_src, num_dst, indptr, indices, edge_ids, formats);
39
40
41
  return HeteroGraphPtr(new HeteroGraph(unit_g->meta_graph(), {unit_g}));
}

42
HeteroGraphPtr CreateFromCSR(
43
    int64_t num_vtypes, const aten::CSRMatrix& mat, dgl_format_code_t formats) {
44
  auto unit_g = UnitGraph::CreateFromCSR(num_vtypes, mat, formats);
45
46
  auto ret = HeteroGraphPtr(new HeteroGraph(unit_g->meta_graph(), {unit_g}));
  return HeteroGraphPtr(new HeteroGraph(unit_g->meta_graph(), {unit_g}));
47
48
49
}

HeteroGraphPtr CreateFromCSC(
50
51
    int64_t num_vtypes, int64_t num_src, int64_t num_dst, IdArray indptr,
    IdArray indices, IdArray edge_ids, dgl_format_code_t formats) {
52
  auto unit_g = UnitGraph::CreateFromCSC(
53
      num_vtypes, num_src, num_dst, indptr, indices, edge_ids, formats);
54
55
56
57
  return HeteroGraphPtr(new HeteroGraph(unit_g->meta_graph(), {unit_g}));
}

HeteroGraphPtr CreateFromCSC(
58
    int64_t num_vtypes, const aten::CSRMatrix& mat, dgl_format_code_t formats) {
59
  auto unit_g = UnitGraph::CreateFromCSC(num_vtypes, mat, formats);
60
61
62
  return HeteroGraphPtr(new HeteroGraph(unit_g->meta_graph(), {unit_g}));
}

63
}  // namespace dgl