Skip to content

An easy-to-use module for dealing with topological data in python.

Notifications You must be signed in to change notification settings

CarsonScott/python-topology

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Python Topology

An easy-to-use module for dealing with topological data in python.


Templates

Templates are used to define the attributes of the nodes and links in a topological space.

template = Template('a', 'b', c=3)

In the code above, we create a new template called template, with attributes a, b, and c. The attributes a and b are both set to None by default, while c is set to 3.

Templates are dictionaries that instantiate python objects. The instantiated objects have the attributes stored within the template from which they were created.

Objects

Objects are the actual nodes and links stored within a topological space.

object = template(1, 2)

In the code above, we create a new object called object, which is instantiated from template. The attributes a and b are assigned to 1 and 2 respectively, while c is assigned to 3 by default. It is possible to overwrite the value of c, as well as to let a and b remain equal to None by simply not providing different values when instantiating the object.

Topological Spaces

Topological spaces are made up of nodes instantiated from node templates, and links between nodes instantiated from link templates.

space = Topology(
    node_template=Template('position'),
    link_template=Template('distance'))

In the code above, we create a new topological space called space, with a node template with attribute position and link template with attribute distance. We instantiate node and link objects through space.

space.create_node('a', position=(0,0))
space.create_node('b', position=(0,5))

Here we create two nodes called a and b. The node a has a position of (0,0) and b has a position of (0,5).

space.create_link('a', 'b', distance=5)

We now create a link between a and b with a distance of 5, based on the positions of the nodes. If we would like to see the list of target nodes for a, we can do so through the following code:

space.get_targets('a')

Which gives us ['b']. We can also view the source nodes for b:

space.get_sources('b')

Which gives us ['a']. We can view the node objects directly through the following code:

space.get_node('a')

As well as the link objects:

space.get_link('a', 'b')

We can remove nodes:

space.remove_node('a')

As well as links:

space.remove_link('a', 'b')

Any time a node is removed, every link associated with that node is also removed.

About

An easy-to-use module for dealing with topological data in python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages