/* Copyright 2020 Alibaba Group Holding Limited. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef GRAPHLEARN_CORE_GRAPH_STORAGE_ADJ_MATRIX_H_
#define GRAPHLEARN_CORE_GRAPH_STORAGE_ADJ_MATRIX_H_

#include <cstdint>
#include <vector>
#include "core/graph/storage/auto_indexing.h"
#include "core/graph/storage/edge_storage.h"
#include "core/graph/storage/types.h"

namespace graphlearn {
namespace io {

class AdjMatrix {
public:
  virtual ~AdjMatrix() = default;

  /// Do some re-organization after data fixed.
  virtual void Build(EdgeStorage* edges) = 0;

  /// Get the total count of source nodes after data fixed.
  virtual IdType Size() const = 0;

  /// Insert an edge to the adjacent matrix.
  virtual void Add(IdType edge_id, IdType src_id, IdType dst_id) = 0;

  /// Get all the neighbor node ids of a given id.
  virtual Array<IdType> GetNeighbors(IdType src_id) const = 0;

  /// Get all the neighbor edge ids of a given id.
  virtual Array<IdType> GetOutEdges(IdType src_id) const = 0;
};

AdjMatrix* NewMemoryAdjMatrix(AutoIndex* indexing);
AdjMatrix* NewCompressedMemoryAdjMatrix(AutoIndex* indexing);

}  // namespace io
}  // namespace graphlearn

#endif  // GRAPHLEARN_CORE_GRAPH_STORAGE_ADJ_MATRIX_H_
