Skip to content

API Reference Topology

Classes:

Name Description
Edge

The internal representaion of a graph edge.

Node

The internal representation of a graph node.

Topology

The internal representation of a topology graph.

TopologyContainer

The class representing a list of topologies.

TopologyGenerator

The main generator class of the topology module.

TopologyModel

A model containing only topological information, i.e. the allowed degrees of nodes.

TopologySelector

A selector class which determines whether a topology is to be kept or to be discarded. The available critera are

Edge

The internal representaion of a graph edge.

Methods:

Name Description
momentum

Get the internal representation of the edge's momentum. The function returns a list of integers, where

nodes

Get a list of the ids of the connected nodes.

momentum() -> list[int]

Get the internal representation of the edge's momentum. The function returns a list of integers, where the i-th entry is the coefficient of the i-th momentum. The first n_ext momenta are external, the remaining momenta are the n_loops loop momenta.

nodes() -> list[int]

Get a list of the ids of the connected nodes.

Node

The internal representation of a graph node.

Methods:

Name Description
adjacent

Get a list of the ids of the adjacent nodes.

degree

Get the degree of the node.

adjacent() -> list[int]

Get a list of the ids of the adjacent nodes.

degree() -> int

Get the degree of the node.

Topology

The internal representation of a topology graph.

Methods:

Name Description
draw_tikz

Draw the topology in the TikZ format

edges

Get a list of all nodes in the topology.

nodes

Get a list of all edges in the topology.

symmetry_factor

Get the topology's symmetry factor

draw_tikz(path: str)

Draw the topology in the TikZ format

edges() -> list[Edge]

Get a list of all nodes in the topology.

nodes() -> list[Node]

Get a list of all edges in the topology.

symmetry_factor() -> int

Get the topology's symmetry factor

TopologyContainer

The class representing a list of topologies.

Methods:

Name Description
__getitem__
__len__
draw

Draw the specified topologies into a large canvas. Returns an SVG string, which can be displayed e.g. in a

query

Query whether there is a topology in the container, which would be selected by selector.

__getitem__(index: int) -> Topology

__len__() -> int

draw(topologies: list[int], n_cols: Optional[int] = 4) -> str

Draw the specified topologies into a large canvas. Returns an SVG string, which can be displayed e.g. in a Jupyter notebook.

Example:

from from IPython.display import SVG
from feyngraph.topology import TopologyGenerator, TopologyModel
topos = TopologyGenerator(4, 0, TopologyModel([3, 4]))
SVG(topos.draw(range(len(topos))))

Parameters:

Name Type Description Default
topologies list[int]

list of IDs of topologies to draw

required
n_cols Optional[int]

number of topologies to draw in each row

4

query(selector: TopologySelector)

Query whether there is a topology in the container, which would be selected by selector.

TopologyGenerator

The main generator class of the topology module.

Examples:

model = TopologyModel([3, 4])
selector = TopologySelector()
selector.select_opi_components(1)
generator = TopologyGenerator(4, 3, model, selector)
topologies = generator.generate()
assert(len(topologies), 6166)

Methods:

Name Description
__new__

Create a new topology generator.

count

Generate the topologies for the given configuration without saving them, only returning the total number.

generate

Generate the topologies for the given configuration.

__new__(n_external: int, n_loops: int, model: TopologyModel, selector: Optional[TopologySelector] = None) -> TopologyGenerator

Create a new topology generator.

Parameters:

Name Type Description Default
selector Optional[TopologySelector]

the selector choosing whether a given topology is kept or discarded. If no selector is specified, all topologies are kept

None

count() -> int

Generate the topologies for the given configuration without saving them, only returning the total number.

generate() -> TopologyContainer

Generate the topologies for the given configuration.

TopologyModel

A model containing only topological information, i.e. the allowed degrees of nodes.

Methods:

Name Description
__new__

Create a new topology model containing nodes with degrees specified in node_degrees.

__new__(node_degrees: list[int]) -> TopologyModel

Create a new topology model containing nodes with degrees specified in node_degrees.

TopologySelector

A selector class which determines whether a topology is to be kept or to be discarded. The available critera are

  • node degrees: select only topologies for which the number of nodes with a specified degree matches any of the given counts
  • node partition: select only topologies matching any of the given node partitions, i.e. a topology for which the number of nodes of each degree exactly matches the count specified in the partition.
  • opi components: select only topologies for which the number of one-particle-irreducible components matches any of the given counts
  • custom functions: select only topologies for which any of the given custom functions return true

Methods:

Name Description
add_custom_function

Add a constraint to only select topologies for which the given function returns true. The function receives

clear

Clear all criteria.

select_node_degree

Add a constraint to only select topologies which contain selection nodes of degree degree.

select_node_degree_range

Add a constraint to only select topologies which contain between start and end nodes of degree degree.

select_node_partition

Add a constraint to only select topologies for which the number of nodes of all given degree exactly matches

select_on_shell

Select only topologies with no self-energy insertions on external legs. This implementation considers internal

select_opi_components

Add a constraints to only select topologies with opi_count one-particle-irreducible components.

select_self_loops

Select only topologies containing exactly n self-loops.

add_custom_function(py_function: Callable[[Topology], bool])

Add a constraint to only select topologies for which the given function returns true. The function receives a single topology as input and should return a boolean.

Examples:

def no_self_loop(topo: feyngraph.topology.Topology) -> bool:
    return any(edge.get_nodes()[0] == edge.get_nodes()[1] for edge in topo.get_edges())

selector = feyngraph.topology.TopologySelector()
selector.add_custom_function(no_self_loop)

clear()

Clear all criteria.

select_node_degree(degree: int, selection: int)

Add a constraint to only select topologies which contain selection nodes of degree degree.

select_node_degree_range(degree: int, start: int, end: int)

Add a constraint to only select topologies which contain between start and end nodes of degree degree.

select_node_partition(partition: list[tuple[int, int]])

Add a constraint to only select topologies for which the number of nodes of all given degree exactly matches he specified count.

Examples:

selector = TopologySelector()
# Select only topologies containing exactly four nodes of degree 3 and one node of degree 4
selector.select_node_partition([(3, 4), (4, 1)])

select_on_shell()

Select only topologies with no self-energy insertions on external legs. This implementation considers internal edges carrying a single external momentum and no loop momentum, which is equivalent to a self-energy insertion on an external edge.

select_opi_components(opi_count: int)

Add a constraints to only select topologies with opi_count one-particle-irreducible components.

select_self_loops(n: int)

Select only topologies containing exactly n self-loops.