qsrlib_qstag.qstag module

Qualitative Spatio-Temporal Activity Graph module

class qsrlib_qstag.qstag.Activity_Graph(world, world_qsr, object_types={}, params={})[source]

Activity Graph class: Lower level is a set of only nodes of type ‘object’. Middle level nodes are only of type ‘spatial_relation’. Top level nodes are only of type ‘temporal_relation’.

Accepts a QSRLib.World_Trace and QSRLib.QSR_World_Trace as input.

abstract_graph

Getter.

Returns:self.abstract_graph
Return type:igraph.Graph
abstract_object_nodes

Getter.

Returns:object_nodes from abstract_graph
Return type:list
episodes

Getter.

Returns:self.__episodes
Return type:list
static get_objects_types(objects_types, world)[source]

Generates a dictionary of object name and object type pairs Using both the dynamic_args dictionary where key = objects_types, and the **kwargs value [object_type] in the World Trace object

Parameters:
  • objects_types (dictionary) – Uses the dynamic_args dictionary where key = objects_types if provided
  • world (World_Trace) – Otherwise, looks at the **kwargs value [object_type] in the World Trace object
Returns:

A dictionary with the object name as keys and the generic object type as value.

Return type:

dict

graph = None

igraph.Graph: An igraph graph object containing all the object, spatial and temporal nodes. list: A list of edges connecting the spatial nodes to the object nodes. list: A list of edges connecting the spatial nodes to the temporal nodes.

graphlets = None

Creates a Graphlets object containing lists of, unique graphlets, hashes and histogram of graphlets.

histogram

Getter.

Returns:self.__histogram
Return type:dict
object_nodes

Getter.

Returns:object_nodes
Return type:list
spatial_nodes

Getter.

Returns:spatial_nodes
Return type:list
spatial_obj_edges

Getter.

Returns:self.__spatial_obj_edges
Return type:list
temp_spatial_edges

Getter.

Returns:self.__temp_spatial_edges
Return type:list
temporal_nodes

Getter.

Returns:temporal_nodes
Return type:list
class qsrlib_qstag.qstag.Graphlets(episodes, params, object_types)[source]

Graphlet class: Minimal subgraphs of the same structure as the Activity Graph.

code_book = None

list: The list of graphlet hashes (zip with histogram for count of each).

graphlets = None

dict: dictionary of the graphlet hash as key, and the iGraph object as value.

histogram = None

list: The list of graphlet counts (zip with codebook for a hash of each, and check graphlets for the iGraph).

qsrlib_qstag.qstag.get_graph(episodes, object_types={})[source]

Generates a graph from a set of input episode QSRs.

Parameters:
  • episodes (list) – list of episodes, where one episode = [[obj_list], {QSR dict}, (start, end_tuple)]
  • object_types (dict) – a dictionary of object ID and object type.
Returns:

igraph.Graph: An igraph graph object containing all the object, spatial and temporal nodes.

Return type:

igraph.Graph

qsrlib_qstag.qstag.get_graphlet_selections(episodes, params, object_types, vis=False)[source]

This function implements Sridar’s validity criteria to select all valid graphlets from an activity graph: see Sridar_AAAI_2010 for more details.

Parameters:
  • episodes (list) – list of episodes, where one episode = [[obj_list], {QSR dict}, (start, end_tuple)]
  • params (dict) – a dictionary containing parameters for the generation of the QSTAG. i.e. “min_rows”, “max_rows”, “max_eps”
Return list_of_graphlets:
 

a list of iGraph graphlet objects

Return type:

list

Return list_of_graphlet_hashes:
 

a list of hashes, relating to the graphlets

Return type:

list