Skip to main content

Graph, Graph Algorithm, and Klang Valley Transit Routing

Project description

Klang Valley Transit

Installation

  1. install from PyPI
pip install klang-valley-transit

sample use case

  1. LRT and MRT station Listing
from klang_valley_transit.trainNetwork import TrainNetwork
from klang_valley_transit.trainNetwork import SearchFilter, LineNameEnum

# initiate the instance
t = TrainNetwork()

# List all LRT and MRT stations
s,err = t.ListStation(SearchFilter(line_name="*"))
if err: raise Exception(err)
print(s)

# List LRT or MRT stations where LineName is AMPANG_LRT
s,err = t.ListStation(SearchFilter(line_name=LineNameEnum.AG))
if err: raise Exception(err)
print(s)

# List AMPANG LRT where the code is AG11
s,err = t.ListStation(SearchFilter(line_name=LineNameEnum.AG, code="AG11"))
if err: raise Exception(err)
print(s)

# Search from all AMPANG LRT stations where station name like sentul
s,err = t.ListStation(SearchFilter(line_name=LineNameEnum.AG, station_name="sentul"))
if err: raise Exception(err)
print(s)
  1. MRT and LRT station routing
from klang_valley_transit.trainNetwork import TrainNetwork

# initiate the instance
t = TrainNetwork()

# getting 2 random station id
[fromID,toID], error = t.getRandomVerticesID(2)
if error: print(error)
print(fromID,toID)

# routing the station base on ID
res,err = t.breadthFirstSearch(fromID,toID)
if err : raise Exception(err)
print("explored : ",res.explored )
print("path : ",res.path)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

klang_valley_transit-1.0.2.tar.gz (24.9 kB view hashes)

Uploaded Source

Built Distribution

klang_valley_transit-1.0.2-py2-none-any.whl (30.9 kB view hashes)

Uploaded Python 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page