• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include "minddata/dataset/engine/gnn/local_edge.h"
17 
18 #include <string>
19 
20 namespace mindspore {
21 namespace dataset {
22 namespace gnn {
23 
LocalEdge(EdgeIdType id,EdgeType type,WeightType weight,std::shared_ptr<Node> src_node,std::shared_ptr<Node> dst_node)24 LocalEdge::LocalEdge(EdgeIdType id, EdgeType type, WeightType weight, std::shared_ptr<Node> src_node,
25                      std::shared_ptr<Node> dst_node)
26     : Edge(id, type, weight, src_node, dst_node) {}
27 
GetFeatures(FeatureType feature_type,std::shared_ptr<Feature> * out_feature)28 Status LocalEdge::GetFeatures(FeatureType feature_type, std::shared_ptr<Feature> *out_feature) {
29   auto itr = features_.find(feature_type);
30   if (itr != features_.end()) {
31     *out_feature = itr->second;
32     return Status::OK();
33   } else {
34     std::string err_msg = "Invalid feature type:" + std::to_string(feature_type);
35     RETURN_STATUS_UNEXPECTED(err_msg);
36   }
37 }
38 
UpdateFeature(const std::shared_ptr<Feature> & feature)39 Status LocalEdge::UpdateFeature(const std::shared_ptr<Feature> &feature) {
40   auto itr = features_.find(feature->type());
41   if (itr != features_.end()) {
42     RETURN_STATUS_UNEXPECTED("Feature already exists");
43   } else {
44     features_[feature->type()] = feature;
45     return Status::OK();
46   }
47 }
48 
49 }  // namespace gnn
50 }  // namespace dataset
51 }  // namespace mindspore
52