コード例 #1
0
    def setUp(self) -> None:
        '''
        Load two networks. The first one is a simple test network, and the second one is the London subway
        stations network(Victoria).

        '''

        # load data (simple network)
        self.network1 = ot.TemporalDiGraph(
            'test_network', data=ot.CsvInput('../overtime/data/network.csv'))

        # load data (London subway stations - Victoria)
        tfl_data = ot.CsvInput(
            '../overtime/data/victoria_central_bakerloo_piccadilly-inbound_outbound.csv'
        )
        self.network2 = ot.TemporalDiGraph('TflNetwork', data=tfl_data)
        self.network2.nodes.add_data(
            '../overtime/data/victoria_central_bakerloo_piccadilly-stations.csv'
        )
コード例 #2
0
import overtime as ot

# load data (simple network)
network1 = ot.TemporalDiGraph(
    'test_network', data=ot.CsvInput('../../overtime/data/network.csv'))

# load data (London subway stations - Victoria)
tfl_data = ot.CsvInput(
    '../../overtime/data/victoria_central_bakerloo_piccadilly-inbound_outbound.csv'
)
network2 = ot.TemporalDiGraph('TflNetwork', data=tfl_data)
network2.nodes.add_data(
    '../../overtime/data/victoria_central_bakerloo_piccadilly-stations.csv')

# timeline - circular layout
# simple network
ot.echarts_Timeline(network1,
                    3,
                    path='../html/network_circular_layout_timeline1.html',
                    title='circular layout timeline',
                    subtitle='simple network',
                    layout='circular')

# timeline - force layout
# simple network
ot.echarts_Timeline(network1,
                    3,
                    path='../html/network_force_layout_timeline2.html',
                    title='force layout timeline',
                    subtitle='simple network',
                    layout='force')
コード例 #3
0
ファイル: network_example.py プロジェクト: overtime3/overtime
import overtime as ot

network = ot.TemporalDiGraph('SampleNetwork', data=ot.CsvInput('./data/network.csv'))

subgraph = network.get_temporal_subgraph(intervals=((0,3),(8,10)), nodes=('a', 'c', 'd'))
subgraph.details()
subgraph.print()
print(subgraph.edges.timespan())



plotter = ot.Plotter()
plotter.single(ot.Circle, network.get_snapshot(7))
plotter.single(ot.Slice, network)

snapshots = []
for t in network.edges.timespan():
    snapshots.append(network.get_snapshot(t))

plotter.multi(ot.Circle, snapshots)

a_tree = ot.calculate_foremost_tree(network, 'a')
print(ot.calculate_reachability(network, 'a'))
plotter.single(ot.Circle, a_tree)

input("Press enter key to exit...")
コード例 #4
0
ファイル: tfl_example.py プロジェクト: soca-git/overtime
import overtime as ot

####################
### Introduction ###
####################

### import central line data & create graph.
central = ot.TemporalDiGraph('CentralLine',
                             data=ot.CsvInput('./data/central-inbound.csv'))
central.nodes  # nodes object
central.edges  # edges object

# nodes
central.nodes.aslist()[0:4]
central.nodes.count()
central.nodes.labels()

# node
lstreet = central.nodes.get('Liverpool Street')
lstreet.sourceof()
lstreet.sourceof().labels()
lstreet.sinkof().labels()
lstreet.sinkof().start_times()
lstreet.sinkof().end_times()
lstreet.nodeof().labels()
lstreet.neighbours()

# edges
central.edges.aslist()
central.edges.count()
central.edges.labels()
コード例 #5
0
import overtime as ot
import pandas as pd


tube = ot.TemporalDiGraph('TubeNetwork', data=ot.CsvInput('./bakerloo-inbound.csv'))
tube.details()

ot.Circle(tube)
plotter = ot.Plotter()
plotter.single(ot.Circle, tube)
ot.Slice(tube)

for node in tube.nodes.set:
    node.data['reachability'] = ot.calculate_reachability(tube, node.label)

ot.NodeScatter(tube, bubble_metric='reachability')

station_df = pd.read_csv("bakerloo-stations.csv")
tube.nodes.add_data(station_df)

ot.NodeScatter(tube, x='lon', y='lat', bubble_metric='reachability')

foremost_oxcirc = ot.calculate_foremost_tree(tube, 'Oxford Circus')
foremost_oxcirc.nodes.add_data(station_df)
ot.NodeScatter(foremost_oxcirc, x='lon', y='lat', bubble_metric='foremost_time')


input("Press enter key to exit...")
コード例 #6
0
    def parse_graph_to_json(self):
        pass


class Temporal_DiGraph_Network_Parser(Graph_Network_Parser):
    def __init__(self, graph):
        super().__init__(graph)
        self.start_time = graph.edges.start_times()
        self.end_time = graph.edges.end_times()

    def parse_graph_to_json(self):
        json_dataset = {}
        json_dataset['nodes'] = self.node_labels
        json_dataset['edges'] = []
        for i in range(len(self.edge_labels)):
            edge = {}
            source_and_target = self.edge_labels[i].split("-")
            edge['source'] = source_and_target[0]
            edge['target'] = source_and_target[1]
            edge['start'] = self.start_time[i]
            edge['end'] = self.end_time[i]
            json_dataset['edges'].append(edge)
        return json.dumps(json_dataset)


underground = ot.TemporalDiGraph(
    'UndergroundLine', data=ot.CsvInput('./data/mini_underground_all.csv'))
visual = Temporal_DiGraph_Network_Parser(underground)
result = visual.parse_graph_to_json()
print(result)
コード例 #7
0
import math
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

import overtime as ot

tube = ot.TemporalDiGraph('TubeNetwork',
                          data=ot.CsvInput('./bakerloo-inbound_outbound.csv'))
tube.details()

station_df = pd.read_csv("bakerloo-stations.csv")
tube.nodes.add_data(station_df)

R = []
for node in tube.nodes.set:
    R.append(ot.calculate_reachability(tube, node.label))

X = [node.data['lon'] for node in tube.nodes.set]
Y = [node.data['lat'] for node in tube.nodes.set]
figure, axis = plt.subplots(1)

plt.subplots_adjust(left=0.05,
                    bottom=0.05,
                    right=0.95,
                    top=0.95,
                    wspace=0,
                    hspace=0)
axis.set_aspect('equal')
plt.scatter(X, Y, s=[(r + 2) * 30 for r in R], c=Y, alpha=0.5)
#axis.set_xticks(range(0, tube.nodes.count()))
コード例 #8
0
ファイル: views.py プロジェクト: overtime3/overtime-tools
def dataset():      # This is hardcode example of dataset, in the future the user can select their own file 
    underground = ot.TemporalDiGraph('UndergroundLine', data=ot.CsvInput('./data/mini_jubilee.csv'))
    visual = Temporal_DiGraph_Network_Parser(underground)
    res = visual.parse_graph_to_json()
    return res