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
f178fd98
Commit
f178fd98
authored
Sep 01, 2020
by
Jean-Baptiste Mazon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add eccentricity
parent
1bc3746a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
Structure.chs
src/IGraph/Algorithms/Structure.chs
+23
-0
Algorithms.hs
tests/Test/Algorithms.hs
+11
-0
No files found.
src/IGraph/Algorithms/Structure.chs
View file @
f178fd98
...
...
@@ -4,6 +4,8 @@ module IGraph.Algorithms.Structure
( -- * Shortest Path Related Functions
shortestPath
, diameter
, eccentricity
-- * Graph Components
, inducedSubgraph
, isConnected
, isStronglyConnected
...
...
@@ -11,6 +13,8 @@ module IGraph.Algorithms.Structure
, isDag
, topSort
, topSortUnsafe
-- * Auxiliary types
, Neimode(IgraphOut,IgraphIn,IgraphAll) -- not IgraphTotal
) where
import Control.Monad
...
...
@@ -88,6 +92,25 @@ diameter graph directed unconn = unsafePerformIO $
, `Bool'
} -> `CInt' void- #}
-- | Eccentricity of some vertices.
eccentricity :: Graph d v e
-> Neimode -- ^ 'IgraphOut' to follow edges' direction,
-- 'IgraphIn' to reverse it, 'IgraphAll' to ignore
-> [Node] -- ^ vertices for which to calculate eccentricity
-> [Double]
eccentricity graph mode vids = unsafePerformIO $
allocaVector $ \res ->
withVerticesList vids $ \vs -> do
igraphEccentricity (_graph graph) res vs mode
toList res
{-# INLINE igraphEccentricity #-}
{#fun igraph_eccentricity as ^
{ `IGraph'
, castPtr `Ptr Vector'
, castPtr %`Ptr VertexSelector'
, `Neimode'
} -> `CInt' void- #}
-- | Creates a subgraph induced by the specified vertices. This function collects
-- the specified vertices and all edges between them to a new graph.
inducedSubgraph :: (Ord v, Serialize v)
...
...
tests/Test/Algorithms.hs
View file @
f178fd98
...
...
@@ -22,6 +22,7 @@ tests = testGroup "Algorithms"
,
motifTest
,
cliqueTest
,
diameterTest
,
eccentricityTest
,
subGraphs
,
decomposeTest
,
pagerankTest
...
...
@@ -64,6 +65,16 @@ diameterTest = testGroup "Diameters"
,
testCase
"ring"
$
fst
(
diameter
(
ring
10
)
U
False
)
@?=
5
]
eccentricityTest
::
TestTree
eccentricityTest
=
testGroup
"Eccentricity"
[
testCase
"clique"
$
eccentricity
(
full
@
'U
10
False
)
IgraphAll
[
0
..
9
]
@?=
replicate
10
1
,
testCase
"star"
$
eccentricity
(
star
10
)
IgraphAll
[
0
..
9
]
@?=
(
1
:
replicate
9
2
)
,
testCase
"ring"
$
eccentricity
(
ring
10
)
IgraphAll
[
0
..
9
]
@?=
replicate
10
5
]
subGraphs
::
TestTree
subGraphs
=
testGroup
"generate induced subgraphs"
[
testCase
""
$
test
case1
]
...
...
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