Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-igraph
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-igraph
Commits
e573be11
Commit
e573be11
authored
8 years ago
by
Kai Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor
parent
d105a1c6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
18 deletions
+26
-18
IGraph.hs
src/IGraph.hs
+5
-5
GEXF.hs
src/IGraph/Exporter/GEXF.hs
+4
-0
Graphics.hs
src/IGraph/Exporter/Graphics.hs
+15
-11
Structure.hs
src/IGraph/Structure.hs
+1
-1
stack.yaml
stack.yaml
+1
-1
No files found.
src/IGraph.hs
View file @
e573be11
...
...
@@ -132,13 +132,13 @@ mkGraph (n, vattr) (es,eattr) = runST $ do
zip'
a
b
|
length
a
/=
length
b
=
error
"incorrect length"
|
otherwise
=
zipWith
(
\
(
x
,
y
)
z
->
(
x
,
y
,
z
))
a
b
fromLabeledEdges
::
(
Graph
d
,
Hashable
v
,
Read
v
,
Eq
v
,
Show
v
)
=>
[(
v
,
v
)]
->
LGraph
d
v
()
fromLabeledEdges
es
=
mkGraph
(
n
,
Just
labels
)
(
es'
,
Nothing
)
fromLabeledEdges
::
(
Graph
d
,
Hashable
v
,
Read
v
,
Eq
v
,
Show
v
,
Show
e
)
=>
[(
(
v
,
v
),
e
)]
->
LGraph
d
v
e
fromLabeledEdges
es
=
mkGraph
(
n
,
Just
labels
)
(
es'
,
Just
$
snd
$
unzip
es
)
where
es'
=
map
(
f
***
f
)
es
es'
=
map
(
f
***
f
)
$
fst
$
unzip
es
where
f
x
=
M
.
lookupDefault
undefined
x
labelToId
labels
=
nub
$
concat
[
[
a
,
b
]
|
(
a
,
b
)
<-
es
]
labels
=
nub
$
concat
[
[
a
,
b
]
|
(
(
a
,
b
),
_
)
<-
es
]
labelToId
=
M
.
fromList
$
zip
labels
[
0
..
]
n
=
M
.
size
labelToId
...
...
This diff is collapsed.
Click to expand it.
src/IGraph/Exporter/GEXF.hs
View file @
e573be11
...
...
@@ -21,6 +21,7 @@ data NodeAttr = NodeAttr
,
_nodeLabel
::
String
,
_positionX
::
Double
,
_positionY
::
Double
,
_nodeZindex
::
Int
}
deriving
(
Show
,
Read
,
Eq
)
instance
Hashable
NodeAttr
where
...
...
@@ -33,6 +34,7 @@ defaultNodeAttributes = NodeAttr
,
_nodeLabel
=
""
,
_positionX
=
0
,
_positionY
=
0
,
_nodeZindex
=
1
}
data
EdgeAttr
=
EdgeAttr
...
...
@@ -40,6 +42,7 @@ data EdgeAttr = EdgeAttr
,
_edgeColour
::
AlphaColour
Double
,
_edgeWeight
::
Double
,
_edgeArrowLength
::
Double
,
_edgeZindex
::
Int
}
deriving
(
Show
,
Read
,
Eq
)
instance
Hashable
EdgeAttr
where
...
...
@@ -51,6 +54,7 @@ defaultEdgeAttributes = EdgeAttr
,
_edgeColour
=
opaque
black
,
_edgeWeight
=
1.0
,
_edgeArrowLength
=
5.0
,
_edgeZindex
=
0
}
genXMLTree
::
(
ArrowXml
a
,
Graph
d
)
=>
LGraph
d
NodeAttr
EdgeAttr
->
a
XmlTree
XmlTree
...
...
This diff is collapsed.
Click to expand it.
src/IGraph/Exporter/Graphics.hs
View file @
e573be11
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GADTs
#-}
module
IGraph.Exporter.Graphics
(
renderGraph
,
graphToDiagram
)
where
import
Diagrams.Prelude
import
Diagrams.Size
(
dims
)
import
Diagrams.Backend.Cairo
import
Data.List
(
sortBy
)
import
Data.Ord
(
comparing
)
import
Diagrams.Backend.Cairo
import
Diagrams.Prelude
import
Diagrams.Size
(
dims
)
import
IGraph
import
IGraph.Exporter.GEXF
import
IGraph
import
IGraph.Exporter.GEXF
renderGraph
::
Graph
d
=>
FilePath
->
Double
->
Double
->
LGraph
d
NodeAttr
EdgeAttr
->
IO
()
renderGraph
out
w
h
gr
=
renderCairo
out
(
dims
$
w
^&
h
)
$
graphToDiagram
gr
graphToDiagram
::
Graph
d
=>
LGraph
d
NodeAttr
EdgeAttr
->
Diagram
B
graphToDiagram
gr
=
position
(
map
drawNode
(
nodes
gr
))
<>
mconcat
(
map
drawEdge
(
edges
gr
))
graphToDiagram
gr
=
mconcat
$
fst
$
unzip
$
sortBy
(
flip
(
comparing
snd
))
$
map
drawNode
(
nodes
gr
)
++
map
drawEdge
(
edges
gr
)
where
drawNode
x
=
(
_positionX
nattr
^&
_positionY
nattr
,
circle
(
_size
nattr
)
#
lwO
0
#
fcA
(
_nodeColour
nattr
)
)
drawNode
x
=
(
moveTo
(
_positionX
nattr
^&
_positionY
nattr
)
(
circle
(
_size
nattr
)
#
lwO
0
#
fcA
(
_nodeColour
nattr
))
,
_nodeZindex
nattr
)
where
nattr
=
nodeLab
gr
x
drawEdge
(
from
,
to
)
=
{-arrowBetween'
...
...
@@ -27,8 +31,8 @@ graphToDiagram gr = position (map drawNode (nodes gr)) <> mconcat (map drawEdge
& arrowHead .~ arrowH
& headLength .~ output (_edgeArrowLength eattr)
) start end-}
fromVertices
[
start
,
end
]
#
lwO
(
_edgeWeight
eattr
)
#
lcA
(
_edgeColour
eattr
)
(
fromVertices
[
start
,
end
]
#
lwO
(
_edgeWeight
eattr
)
#
lcA
(
_edgeColour
eattr
)
,
_edgeZindex
eattr
)
where
eattr
=
edgeLab
gr
(
from
,
to
)
start
=
_positionX
nattr1
^&
_positionY
nattr1
...
...
This diff is collapsed.
Click to expand it.
src/IGraph/Structure.hs
View file @
e573be11
...
...
@@ -84,7 +84,7 @@ eigenvectorCentrality gr ws = unsafePerformIO $ do
-- | Google's PageRank
pagerank
::
Graph
d
=>
LGraph
d
v
e
->
Maybe
[
Double
]
->
Maybe
[
Double
]
-- ^ edge weights
->
Double
-- ^ damping factor, usually around 0.85
->
[
Double
]
pagerank
gr
ws
d
=
unsafePerformIO
$
alloca
$
\
p
->
do
...
...
This diff is collapsed.
Click to expand it.
stack.yaml
View file @
e573be11
...
...
@@ -4,4 +4,4 @@ flags:
packages
:
-
'
.'
extra-deps
:
[]
resolver
:
lts-
5.5
resolver
:
lts-
6.1
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment