2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ============LICENSE_END=========================================================
18 package org.onap.dcae.runtime.core;
20 import com.google.common.graph.MutableNetwork;
21 import com.google.common.graph.NetworkBuilder;
25 public class FlowGraph<Node,Edge> {
28 private boolean isMain;
29 private String description;
30 private MutableNetwork<Node,Edge> mutableNetwork;
32 public FlowGraph(String id, String name, boolean isMain, String description) {
36 this.description = description;
37 this.mutableNetwork = NetworkBuilder.directed().build();
40 public String getId() {
44 public void setId(String id) {
48 public String getName() {
52 public void setName(String name) {
56 public boolean isMain() {
60 public void setMain(boolean main) {
64 public String getDescription() {
68 public void setDescription(String description) {
69 this.description = description;
72 public void addNode(Node node) {
73 mutableNetwork.addNode(node);
76 public int getNodeSize() {
77 return mutableNetwork.nodes().size();
80 public Set<Node> getNodes() {
81 return mutableNetwork.nodes();
84 public Set<Edge> getEdges() {
85 return mutableNetwork.edges();
88 public void addEdge(Node node_1, Node node_2, Edge edge) {
89 mutableNetwork.addEdge(node_1,node_2,edge);
92 public int getEdgeSize() {
93 return mutableNetwork.edges().size();
96 public Edge getEdge(Node node_1, Node node_2) {
97 return mutableNetwork.edgeConnecting(node_1,node_2).get();
100 public void removeNode(Node node_1) {
101 mutableNetwork.removeNode(node_1);
104 public void removeEdge(Edge edge_1) {
105 mutableNetwork.removeEdge(edge_1);