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
  1. install directly from github repository
pip install git+https://gitlab.com/packages4240711/klangvalleytransit@master

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(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(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(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(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(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.1.tar.gz (25.0 kB view hashes)

Uploaded Source

Built Distributions

klang_valley_transit-1.0.1-py3-none-any.whl (30.9 kB view hashes)

Uploaded Python 3

klang_valley_transit-1.0.1-py2-none-any.whl (31.0 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