isPipelineValid = (data, edgeMap) => {
    const { source, destination } = data;
    const visitedNodes = {};

    let currentNode = source.id, isValid = false;
    while (currentNode && !visitedNodes[currentNode]) {

        if (currentNode === destination.id) {
            isValid = true;
            break;
        }

        visitedNodes[currentNode] = true;
        const currentNodeEdges = filter(edgeMap, { source: currentNode });
        //there should be exactly one edge from the node.
        if (currentNodeEdges.length !== 1) {
            break;
        }
        const currentEdge = currentNodeEdges[0];
        currentNode = currentEdge.target;
    }
    return isValid;
}
Ensure that there are edges connecting from source to destination node