/*!
 * Copyright (C) 2017 AT&T Intellectual Property. 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.
 */

export default class Graph {
	constructor() {
		this.nodes = {};
	}

	addNode(node) {
		this.nodes[node] = [];
	}

	hasNode(node) {
		return this.nodes.hasOwnProperty(node);
	}

	addEdge(firstNode, secondNode, payload) {
		if (!this.hasNode(firstNode)) {
			this.addNode(firstNode);
		}

		if (!this.hasNode(secondNode)) {
			this.addNode(secondNode);
		}

		this.nodes[firstNode].push({...payload, target: secondNode});
	}

	getEdges(node) {
		return this.nodes[node];
	}
}