Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
PRIMO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Social Cognitive Systems
PRIMO
Commits
73f65332
Commit
73f65332
authored
12 years ago
by
Lukas Kettenbach
Browse files
Options
Downloads
Patches
Plain Diff
NetworkX is now dep! install it first
parent
ee11637f
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
core/BayesNet.py
+1
-2
1 addition, 2 deletions
core/BayesNet.py
core/DynamicBayesNet.py
+12
-0
12 additions, 0 deletions
core/DynamicBayesNet.py
examples/DynamicBayesNet.py
+26
-0
26 additions, 0 deletions
examples/DynamicBayesNet.py
examples/__init__.py
+1
-0
1 addition, 0 deletions
examples/__init__.py
with
40 additions
and
2 deletions
core/BayesNet.py
+
1
−
2
View file @
73f65332
import
sys
sys
.
path
.
append
(
"
lib/networkx-1.7-py2.7.egg
"
)
import
networkx
as
nx
from
core.Node
import
Node
...
...
@@ -117,7 +116,7 @@ class BayesNet(object):
def
clear
(
self
):
'''
Remove all nodes and edges from the graph.
This also removes the name, and all graph, node
,
and edge attributes.
'''
This also removes the name, and all graph, node and edge attributes.
'''
self
.
graph
.
clear
()
self
.
node_lookup
.
clear
()
...
...
This diff is collapsed.
Click to expand it.
core/DynamicBayesNet.py
+
12
−
0
View file @
73f65332
...
...
@@ -8,3 +8,15 @@ class DynamicBayesNet(BayesNet):
def
__init__
(
self
):
super
(
DynamicBayesNet
,
self
).
__init__
()
def
add_edge
(
self
,
node_from
,
node_to
,
arc
=
False
):
'''
Add an directed edge to the graph.
Keyword arguments:
node_from -- from node
node_to -- to node
arc -- is this edge a temporal conditional dependency (default: False)
'''
super
().
add_edge
(
node_from
,
node_to
)
# Adding an edge that already exists updates the edge data.
self
.
graph
.
add_edge
(
node_from
,
node_to
,
arc
=
arc
)
This diff is collapsed.
Click to expand it.
examples/DynamicBayesNet.py
100644 → 100755
+
26
−
0
View file @
73f65332
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from
core.BayesNet
import
*
from
reasoning.DiscreteNode
import
DiscreteNode
bn
=
BayesNet
()
burglary
=
DiscreteNode
(
"
Burglary
"
,
[
"
Intruder
"
,
"
Safe
"
])
alarm
=
DiscreteNode
(
"
Alarm
"
,
[
"
Ringing
"
,
"
Silent
"
,
"
Kaputt
"
])
earthquake
=
DiscreteNode
(
"
Earthquake
"
,
[
"
Shaking
"
,
"
Calm
"
])
john_calls
=
DiscreteNode
(
"
John calls
"
,
[
"
Calling
"
,
"
Not Calling
"
])
mary_calls
=
DiscreteNode
(
"
Mary calls
"
,
[
"
Calling
"
,
"
Not Calling
"
])
bn
.
add_node
(
burglary
)
bn
.
add_node
(
alarm
)
bn
.
add_node
(
earthquake
)
bn
.
add_node
(
john_calls
)
bn
.
add_node
(
mary_calls
)
bn
.
add_edge
(
burglary
,
alarm
)
bn
.
add_edge
(
earthquake
,
alarm
)
bn
.
add_edge
(
alarm
,
john_calls
)
bn
.
add_edge
(
alarm
,
mary_calls
)
bn
.
draw
()
This diff is collapsed.
Click to expand it.
examples/__init__.py
+
1
−
0
View file @
73f65332
# -*- coding: utf-8 -*-
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