def bellman_ford(self, source):
        if self.oriented is False:
            print 'cannot apply bellman_ford, graph is not oriented'
            return
        dist = np.array([np.Infinity for x in range(self.n)], dtype=np.float32)
        pred = np.empty((self.n), dtype=np.int)
        pred[source] = source
        dist[source] = 0

        for i in np.arange(1, self.n):
            for e in range(len(self.edges)):
                if dist[self.edges[e][0]] + self.costs[e] < dist[self.edges[e][1]]:
                    dist[self.edges[e][1]] = dist[
                        self.edges[e][0]] + self.costs[e]
                    pred[self.edges[e][1]] = self.edges[e][0]

        for e in range(len(self.edges)):
            if dist[self.edges[e][1]] > dist[self.edges[e][0]] + self.costs[e]:
                print 'Error, Graph contains a negative-weight cycle'
                break

        edges = np.array([], dtype=object)
        for v in range(len(pred)):
            edges = np.append(edges, None)
            edges[-1] = [pred[v], v]

        return edges  # , prev, dist
Save mappings based on user specifications.
dataset/ETHPy150Open dnlcrl/PyGraphArt/src/graph.py/Graph.bellman_ford--crossover with--dataset/ETHPy150Open buildingenergy/buildingenergy-platform/seed/tests/test_tasks.py/TestTasks.test_map_data