Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automata-logic-project2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
User expired
automata-logic-project2
Commits
5e2a3ad3
Commit
5e2a3ad3
authored
3 years ago
by
Valerian Wintner
Browse files
Options
Downloads
Patches
Plain Diff
only red nodes in predecessor
parent
52202216
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
TODO.md
+3
-3
3 additions, 3 deletions
TODO.md
src/arena.rs
+18
-41
18 additions, 41 deletions
src/arena.rs
src/main.rs
+6
-10
6 additions, 10 deletions
src/main.rs
with
27 additions
and
54 deletions
TODO.md
+
3
−
3
View file @
5e2a3ad3
-
extract nodes and edges from original graph
-
extract nodes and edges from original graph
-- done
-
add custom attribute for:
-
color
-
starting position
-
goal position
-
run algorithm on custom data structure (map of sets?)
-
goal position
-- done
-
run algorithm on custom data structure (map of sets?)
-- done
-
cli
-
different executable for displaying the graph, and for running the strategy-check
-
validity-check of input.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/arena.rs
+
18
−
41
View file @
5e2a3ad3
...
...
@@ -6,52 +6,30 @@ use std::collections::{HashMap, HashSet};
use
std
::
hash
::
Hash
;
#[derive(PartialOrd,
Ord,
Clone,
Debug)]
pub
enum
Playing
Node
{
Red
{
id
:
String
,
counter
:
u32
},
Green
{
id
:
String
}
,
pub
struct
Red
Node
{
pub
id
:
String
,
pub
counter
:
u32
,
}
impl
PlayingNode
{
pub
fn
id
(
&
self
)
->
&
String
{
match
self
{
PlayingNode
::
Red
{
id
,
..
}
=>
id
,
PlayingNode
::
Green
{
id
}
=>
id
,
}
}
}
impl
PartialEq
for
PlayingNode
{
impl
PartialEq
for
RedNode
{
fn
eq
(
&
self
,
other
:
&
Self
)
->
bool
{
match
(
self
,
other
)
{
(
Self
::
Red
{
id
:
l_id
,
counter
:
l_counter
,
},
Self
::
Red
{
id
:
r_id
,
counter
:
r_counter
,
},
)
=>
l_id
==
r_id
&&
l_counter
==
r_counter
,
(
Self
::
Green
{
id
:
l_id
},
Self
::
Green
{
id
:
r_id
})
=>
l_id
==
r_id
,
(
_
,
_
)
=>
false
,
}
self
.id
==
other
.id
&&
self
.counter
==
other
.counter
}
}
impl
Eq
for
Playing
Node
{}
impl
Eq
for
Red
Node
{}
impl
Hash
for
Playing
Node
{
impl
Hash
for
Red
Node
{
fn
hash
<
H
>
(
&
self
,
state
:
&
mut
H
)
where
H
:
std
::
hash
::
Hasher
,
{
self
.id
()
.hash
(
state
);
self
.id
.hash
(
state
);
}
}
pub
type
Nodes
=
Vec
<
String
>
;
pub
type
Predecessors
=
HashMap
<
String
,
HashSet
<
Playing
Node
>>
;
pub
type
Predecessors
=
HashMap
<
String
,
HashSet
<
Red
Node
>>
;
pub
type
Successors
=
HashMap
<
String
,
HashSet
<
String
>>
;
pub
type
WinningPositions
=
HashSet
<
String
>
;
pub
type
AdditionalWinning
=
HashSet
<
String
>
;
...
...
@@ -67,16 +45,15 @@ fn insert_node(node: String, additional_winning: &mut AdditionalWinning, pred: &
predecessors
.and_modify
(|
predecessors
|
{
let
mut
changed_predecessors
=
HashSet
::
new
();
for
predecessor
in
predecessors
.iter
()
{
if
let
PlayingNode
::
Red
{
id
,
counter
}
=
predecessor
{
let
counter
=
counter
-
1
;
if
counter
==
0
{
to_insert
.push
(
id
.clone
());
}
else
{
changed_predecessors
.insert
(
PlayingNode
::
Red
{
id
:
id
.clone
(),
counter
,
});
}
let
RedNode
{
id
,
counter
}
=
predecessor
;
let
counter
=
counter
-
1
;
if
counter
==
0
{
to_insert
.push
(
id
.clone
());
}
else
{
changed_predecessors
.insert
(
RedNode
{
id
:
id
.clone
(),
counter
,
});
}
}
*
predecessors
=
changed_predecessors
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
6
−
10
View file @
5e2a3ad3
...
...
@@ -98,19 +98,15 @@ fn build_inputs(g: &Graph) -> (Nodes, Nodes, WinningPositions, Successors, Prede
}
// Finally, add the predecessors. Here, the count is needed, initialized with the #outgoing_edges for red nodes.
for
(
predecessor
,
successors
)
in
&
succ
{
let
pre_node
=
if
reds
.contains
(
predecessor
)
{
PlayingNode
::
Red
{
if
reds
.contains
(
predecessor
)
{
let
pre_node
=
RedNode
{
id
:
predecessor
.clone
(),
counter
:
successors
.len
()
as
u32
,
};
for
successor
in
successors
{
let
predecessors
=
pred
.entry
(
successor
.clone
())
.or_default
();
predecessors
.insert
(
pre_node
.clone
());
}
}
else
{
PlayingNode
::
Green
{
id
:
predecessor
.clone
(),
}
};
for
successor
in
successors
{
let
predecessors
=
pred
.entry
(
successor
.clone
())
.or_default
();
predecessors
.insert
(
pre_node
.clone
());
}
}
}
...
...
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