or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

algorithms.mdanalysis-metrics.mdcore-hypergraph.mdindex.mdutilities.mdvisualization.md

analysis-metrics.mddocs/

0

# Analysis and Metrics

1

2

Structural analysis including connectivity, distance measures, diameter calculations, and component analysis. Supports s-connected analysis for higher-order connectivity patterns in hypergraphs.

3

4

## Capabilities

5

6

### Connectivity Analysis

7

8

Analyze hypergraph connectivity patterns using s-connectivity, which generalizes traditional graph connectivity to hypergraphs by considering edges of different sizes.

9

10

```python { .api }

11

def is_connected(self, s: int = 1, edges: bool = False) -> bool:

12

"""

13

Check if hypergraph is s-connected.

14

15

Parameters:

16

- s: Connectivity level (nodes connected through edges of size ≥ s+1)

17

- edges: Check edge connectivity instead of node connectivity

18

19

Returns:

20

True if hypergraph is s-connected

21

"""

22

23

def connected_components(self, edges: bool = False) -> List[set]:

24

"""

25

Get connected components (equivalent to s=1 connectivity).

26

27

Parameters:

28

- edges: Return edge components instead of node components

29

30

Returns:

31

List of component sets

32

"""

33

34

def s_connected_components(

35

self,

36

s: int = 1,

37

edges: bool = True,

38

return_singletons: bool = False

39

) -> List[set]:

40

"""

41

Get s-connected components.

42

43

Parameters:

44

- s: Connectivity level

45

- edges: Return edge components (True) or node components (False)

46

- return_singletons: Include singleton components

47

48

Returns:

49

List of s-connected component sets

50

"""

51

52

def connected_component_subgraphs(

53

self,

54

return_singletons: bool = True,

55

name: Optional[str] = None

56

) -> List["Hypergraph"]:

57

"""Get connected components as separate hypergraphs."""

58

59

def s_component_subgraphs(

60

self,

61

s: int = 1,

62

edges: bool = True,

63

return_singletons: bool = False,

64

name: Optional[str] = None

65

) -> List["Hypergraph"]:

66

"""Get s-connected components as separate hypergraphs."""

67

```

68

69

### Distance and Diameter

70

71

Calculate distances and diameters in hypergraphs using s-walks that traverse edges of appropriate sizes.

72

73

```python { .api }

74

def distance(

75

self,

76

source: Union[str, int],

77

target: Union[str, int],

78

s: int = 1

79

) -> Union[int, float]:

80

"""

81

Shortest s-walk distance between two nodes.

82

83

Parameters:

84

- source: Source node identifier

85

- target: Target node identifier

86

- s: Walk level (traverse edges of size ≥ s+1)

87

88

Returns:

89

Distance as number of steps, or infinity if unreachable

90

"""

91

92

def edge_distance(

93

self,

94

source: Union[str, int],

95

target: Union[str, int],

96

s: int = 1

97

) -> Union[int, float]:

98

"""

99

Shortest s-walk distance between two edges.

100

101

Parameters:

102

- source: Source edge identifier

103

- target: Target edge identifier

104

- s: Walk level

105

106

Returns:

107

Distance between edges

108

"""

109

110

def diameter(self, s: int = 1) -> Union[int, float]:

111

"""

112

Hypergraph s-diameter (maximum distance between any two nodes).

113

114

Parameters:

115

- s: Diameter level

116

117

Returns:

118

Maximum distance, or infinity if disconnected

119

"""

120

121

def edge_diameter(self, s: int = 1) -> Union[int, float]:

122

"""

123

Edge s-diameter (maximum distance between any two edges).

124

125

Parameters:

126

- s: Diameter level

127

128

Returns:

129

Maximum edge distance

130

"""

131

132

def node_diameters(self, s: int = 1) -> List[Union[int, float]]:

133

"""

134

Node diameters of each connected component.

135

136

Parameters:

137

- s: Diameter level

138

139

Returns:

140

List of component diameters

141

"""

142

143

def edge_diameters(self, s: int = 1) -> List[Union[int, float]]:

144

"""Edge diameters of each connected component."""

145

```

146

147

### Equivalence Classes and Collapsing

148

149

Identify and work with equivalent structures in hypergraphs.

150

151

```python { .api }

152

def equivalence_classes(self, edges: bool = True) -> Dict:

153

"""

154

Get equivalence classes of edges or nodes.

155

156

Parameters:

157

- edges: Get edge equivalence classes (True) or node equivalence classes (False)

158

159

Returns:

160

Dictionary mapping representatives to equivalence class members

161

"""

162

```

163

164

### Linegraph Construction

165

166

Create linegraphs and s-linegraphs for hypergraph analysis.

167

168

```python { .api }

169

def get_linegraph(

170

self,

171

s: int = 1,

172

edges: bool = True

173

):

174

"""

175

Create s-linegraph where nodes represent edges/nodes and edges represent s-adjacency.

176

177

Parameters:

178

- s: Linegraph level

179

- edges: Create edge linegraph (True) or node linegraph (False)

180

181

Returns:

182

NetworkX graph representing the s-linegraph

183

"""

184

```