Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sasa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
verimag
synchrone
sasa
Commits
98be49bc
Commit
98be49bc
authored
5 years ago
by
erwan
Browse files
Options
Downloads
Patches
Plain Diff
Add a function in Algo that states if the graph is directed
parent
b0e6aa76
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/algo/algo.ml
+2
-1
2 additions, 1 deletion
lib/algo/algo.ml
lib/algo/algo.mli
+2
-1
2 additions, 1 deletion
lib/algo/algo.mli
lib/sasacore/register.ml
+58
-26
58 additions, 26 deletions
lib/sasacore/register.ml
lib/sasacore/register.mli
+3
-1
3 additions, 1 deletion
lib/sasacore/register.mli
with
65 additions
and
29 deletions
lib/algo/algo.ml
+
2
−
1
View file @
98be49bc
(* Time-stamp: <modified the
0
7/10/2019 (at 1
5
:0
2
) by Erwan Jahier> *)
(* Time-stamp: <modified the
1
7/10/2019 (at
2
1:0
9
) by Erwan Jahier> *)
open
Sasacore
(* Process programmer API *)
...
...
@@ -105,6 +105,7 @@ let mean_degree = Register.mean_degree
let
max_degree
=
Register
.
max_degree
let
is_cyclic
=
Register
.
is_cyclic
let
is_connected
=
Register
.
is_connected
let
is_directed
=
Register
.
is_directed
let
is_tree
=
Register
.
is_tree
let
height
=
Register
.
height
let
links_number
=
Register
.
links_number
...
...
This diff is collapsed.
Click to expand it.
lib/algo/algo.mli
+
2
−
1
View file @
98be49bc
(* Time-stamp: <modified the
0
7/10/2019 (at
14:35
) by Erwan Jahier> *)
(* Time-stamp: <modified the
1
7/10/2019 (at
21:08
) by Erwan Jahier> *)
(** The Algorithm programming Interface.
A SASA process is an instance of an algorithm defined via this
...
...
@@ -64,6 +64,7 @@ val card : unit -> int
val
min_degree
:
unit
->
int
val
mean_degree
:
unit
->
float
val
max_degree
:
unit
->
int
val
is_directed
:
unit
->
bool
val
is_cyclic
:
unit
->
bool
val
is_connected
:
unit
->
bool
val
is_tree
:
unit
->
bool
...
...
This diff is collapsed.
Click to expand it.
lib/sasacore/register.ml
+
58
−
26
View file @
98be49bc
(* Time-stamp: <modified the
0
7/10/2019 (at 1
0
:0
0
) by Erwan Jahier> *)
(* Time-stamp: <modified the
1
7/10/2019 (at
2
1:0
8
) by Erwan Jahier> *)
type
'
s
neighbor
=
{
state
:
'
s
;
...
...
@@ -29,6 +29,7 @@ type 's internal_tables = {
mutable
is_cyclic
:
bool
option
;
mutable
is_connected
:
bool
option
;
mutable
is_tree
:
bool
option
;
mutable
is_directed
:
bool
option
;
mutable
height
:
(
string
->
int
);
mutable
links_number
:
int
;
mutable
diameter
:
int
;
...
...
@@ -39,6 +40,7 @@ type properties_functions = {
mutable
min_max
:
unit
->
int
*
int
;
mutable
mean_deg
:
unit
->
float
;
mutable
is_connected_cyclic
:
unit
->
bool
*
bool
;
mutable
is_directed
:
unit
->
bool
;
mutable
links_number
:
unit
->
int
;
mutable
diameter
:
unit
->
int
}
...
...
@@ -61,6 +63,7 @@ let (tbls:'s internal_tables) = {
is_cyclic
=
None
;
is_connected
=
None
;
is_tree
=
None
;
is_directed
=
None
;
height
=
(
fun
_
->
-
1
);
links_number
=
(
-
1
);
diameter
=
(
-
1
)
...
...
@@ -71,6 +74,7 @@ let (prop_funs:properties_functions) = {
min_max
=
(
fun
()
->
(
-
1
,-
1
));
mean_deg
=
(
fun
()
->
-
1
.
);
is_connected_cyclic
=
(
fun
()
->
(
false
,
false
));
is_directed
=
(
fun
()
->
false
);
links_number
=
(
fun
()
->
-
1
);
diameter
=
(
fun
()
->
-
1
)
}
...
...
@@ -177,20 +181,33 @@ let set_connec_cycl : (unit -> unit) =
tbls
.
is_connected
<-
Some
x
;
tbls
.
is_cyclic
<-
Some
y
let
(
card
:
unit
->
int
)
=
fun
()
->
match
tbls
.
card
with
|
-
1
->
(
let
c
=
prop_funs
.
card
()
in
tbls
.
card
<-
c
;
c
)
let
(
card
:
unit
->
int
)
=
fun
()
->
match
tbls
.
card
with
|
-
1
->
let
c
=
prop_funs
.
card
()
in
tbls
.
card
<-
c
;
c
|
c
->
c
let
(
is_directed
:
unit
->
bool
)
=
fun
()
->
match
tbls
.
is_directed
with
|
None
->
let
c
=
prop_funs
.
is_directed
()
in
tbls
.
is_directed
<-
Some
c
;
c
|
Some
c
->
c
let
(
min_degree
:
unit
->
int
)
=
fun
()
->
match
tbls
.
min_deg
with
|
-
1
->
(
set_min_max
()
;
tbls
.
min_deg
)
|
m
->
m
let
(
mean_degree
:
unit
->
float
)
=
fun
()
->
match
tbls
.
mean_deg
with
|
-
1
.
->
(
let
m
=
prop_funs
.
mean_deg
()
in
tbls
.
mean_deg
<-
m
;
m
)
let
(
mean_degree
:
unit
->
float
)
=
fun
()
->
match
tbls
.
mean_deg
with
|
-
1
.
->
let
m
=
prop_funs
.
mean_deg
()
in
tbls
.
mean_deg
<-
m
;
m
|
m
->
m
let
(
max_degree
:
unit
->
int
)
=
...
...
@@ -198,25 +215,30 @@ let (max_degree : unit -> int) =
|
-
1
->
(
set_min_max
()
;
tbls
.
max_deg
)
|
m
->
m
let
(
is_cyclic
:
unit
->
bool
)
=
fun
()
->
match
tbls
.
is_cyclic
with
|
None
->
(
set_connec_cycl
()
;
match
tbls
.
is_cyclic
with
|
Some
b
->
b
|
_
->
assert
false
)
let
(
is_cyclic
:
unit
->
bool
)
=
fun
()
->
match
tbls
.
is_cyclic
with
|
None
->
set_connec_cycl
()
;
(
match
tbls
.
is_cyclic
with
|
Some
b
->
b
|
_
->
assert
false
)
|
Some
b
->
b
let
(
is_connected
:
unit
->
bool
)
=
fun
()
->
match
tbls
.
is_connected
with
|
None
->
(
set_connec_cycl
()
;
match
tbls
.
is_connected
with
|
Some
b
->
b
|
_
->
assert
false
)
let
(
is_connected
:
unit
->
bool
)
=
fun
()
->
match
tbls
.
is_connected
with
|
None
->
(
set_connec_cycl
()
;
match
tbls
.
is_connected
with
|
Some
b
->
b
|
_
->
assert
false
)
|
Some
b
->
b
let
(
is_tree
:
unit
->
bool
)
=
fun
()
->
match
tbls
.
is_tree
with
|
None
->
(
let
b
=
(
not
(
is_cyclic
()
)
&&
(
is_connected
()
))
in
tbls
.
is_tree
<-
Some
b
;
b
)
let
(
is_tree
:
unit
->
bool
)
=
fun
()
->
match
tbls
.
is_tree
with
|
None
->
let
b
=
(
not
(
is_cyclic
()
)
&&
(
is_connected
()
))
in
tbls
.
is_tree
<-
Some
b
;
b
|
Some
b
->
b
(* Caution : this option is not the same as the option in the type tbls.height.
...
...
@@ -229,14 +251,21 @@ let height : (unit -> (string -> int) option) =
let
(
links_number
:
unit
->
int
)
=
fun
()
->
match
tbls
.
links_number
with
|
-
1
->
(
let
n
=
prop_funs
.
links_number
()
in
tbls
.
links_number
<-
n
;
n
)
fun
()
->
match
tbls
.
links_number
with
|
-
1
->
let
n
=
prop_funs
.
links_number
()
in
tbls
.
links_number
<-
n
;
n
|
n
->
n
let
(
diameter
:
unit
->
int
)
=
fun
()
->
match
tbls
.
diameter
with
|
-
1
->
(
let
d
=
(
prop_funs
.
diameter
()
)
in
tbls
.
diameter
<-
d
;
d
)
|
-
1
->
let
d
=
(
prop_funs
.
diameter
()
)
in
tbls
.
diameter
<-
d
;
d
|
d
->
d
...
...
@@ -244,6 +273,9 @@ let (diameter : unit -> int) =
let
set_card
:
((
unit
->
int
)
->
unit
)
=
fun
f
->
prop_funs
.
card
<-
f
let
set_is_directed
:
((
unit
->
bool
)
->
unit
)
=
fun
f
->
prop_funs
.
is_directed
<-
f
let
set_degrees
:
((
unit
->
int
*
int
)
->
unit
)
=
fun
f
->
prop_funs
.
min_max
<-
f
...
...
This diff is collapsed.
Click to expand it.
lib/sasacore/register.mli
+
3
−
1
View file @
98be49bc
(* Time-stamp: <modified the
0
7/10/2019 (at
1
0:
00
) by Erwan Jahier> *)
(* Time-stamp: <modified the
1
7/10/2019 (at
2
0:
45
) by Erwan Jahier> *)
(** This module duplicates and extends the Algo module with get_*
functions.
...
...
@@ -37,6 +37,7 @@ val max_degree : unit -> int
val
is_cyclic
:
unit
->
bool
val
is_connected
:
unit
->
bool
val
is_tree
:
unit
->
bool
val
is_directed
:
unit
->
bool
(** If height () = None, then the graph doesn't have a height (because it isn't a tree)
Otherwise, height () = Some h.*)
...
...
@@ -67,6 +68,7 @@ val set_card : (unit -> int) -> unit
val
set_degrees
:
(
unit
->
int
*
int
)
->
unit
val
set_mean_deg
:
(
unit
->
float
)
->
unit
val
set_is_connected_cyclic
:
(
unit
->
bool
*
bool
)
->
unit
val
set_is_directed
:
(
unit
->
bool
)
->
unit
type
node_id
=
string
(* cf topology.mli *)
val
set_height
:
(
node_id
->
int
)
->
unit
val
set_links_number
:
(
unit
->
int
)
->
unit
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment