Commit 0afcba5e authored by Alexandre Delanoë's avatar Alexandre Delanoë

[CLEAN] Towards bipartite graph

parent 37484f3f
...@@ -119,12 +119,14 @@ updateGraphCpt = here.component "updateGraph" cpt where ...@@ -119,12 +119,14 @@ updateGraphCpt = here.component "updateGraph" cpt where
, callback: \val -> T.write_ val methodGraphNodeType1 , callback: \val -> T.write_ val methodGraphNodeType1
, print: show } [] , print: show } []
, H.text "NodeType 2 ?" --}
, H.text "Ngrams ?"
, formChoiceSafe { items: [GT.CTabTerms, GT.CTabSources, GT.CTabAuthors, GT.CTabInstitutes] , formChoiceSafe { items: [GT.CTabTerms, GT.CTabSources, GT.CTabAuthors, GT.CTabInstitutes]
, default: methodGraphNodeType2' , default: methodGraphNodeType2'
, callback: \val -> T.write_ val methodGraphNodeType2 , callback: \val -> T.write_ val methodGraphNodeType2
, print: show } [] , print: show } []
{-
, H.text "Show Strong (expected) links or weak (maybe unexpected) links?" , H.text "Show Strong (expected) links or weak (maybe unexpected) links?"
, formChoiceSafe { items: [Strong, Weak] , formChoiceSafe { items: [Strong, Weak]
, default: methodGraphEdgesStrength' , default: methodGraphEdgesStrength'
......
...@@ -370,12 +370,12 @@ convert (GET.GraphData r) = Tuple r.metaData $ SigmaxT.Graph {nodes, edges} ...@@ -370,12 +370,12 @@ convert (GET.GraphData r) = Tuple r.metaData $ SigmaxT.Graph {nodes, edges}
-- | See sigmajs/plugins/sigma.renderers.customShapes/shape-library.js -- | See sigmajs/plugins/sigma.renderers.customShapes/shape-library.js
modeGraphType :: Types.Mode -> String modeGraphType :: Types.Mode -> String
modeGraphType Types.Authors = "square" modeGraphType Types.Authors = "ccircle"
modeGraphType Types.Institutes = "equilateral" modeGraphType Types.Institutes = "square"
modeGraphType Types.Sources = "star" modeGraphType Types.Sources = "diamond"
--modeGraphType Types.Terms = "def" --modeGraphType Types.Terms = "def"
--modeGraphType Types.Terms = "circle" --modeGraphType Types.Terms = "circle"
modeGraphType Types.Terms = "ccircle" modeGraphType Types.Terms = "triangle"
-------------------------------------------------------------- --------------------------------------------------------------
...@@ -437,7 +437,7 @@ transformGraph graph { edgeConfluence' ...@@ -437,7 +437,7 @@ transformGraph graph { edgeConfluence'
selectedEdgeIds = selectedEdgeIds =
Set.fromFoldable Set.fromFoldable
$ Seq.map _.id $ Seq.map _.id
$ SigmaxT.neighbouringEdges graph selectedNodeIds' $ SigmaxT.neighboringEdges graph selectedNodeIds'
hasSelection = not $ Set.isEmpty selectedNodeIds' hasSelection = not $ Set.isEmpty selectedNodeIds'
newEdges' = Seq.filter edgeFilter $ Seq.map ( newEdges' = Seq.filter edgeFilter $ Seq.map (
......
...@@ -529,7 +529,7 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where ...@@ -529,7 +529,7 @@ neighborhoodCpt = R.memo' $ here.component "neighborhood" cpt where
let refreshed = neighbourBadges graph' selectedNodeIds' let refreshed = neighbourBadges graph' selectedNodeIds'
let count = Seq.length refreshed let count = Seq.length refreshed
let ordered = A.sortWith (\n -> -n.size) $ Seq.toUnfoldable refreshed let ordered = A.sortWith (\n -> -n.size) $ Seq.toUnfoldable refreshed
T.write_ count termCountBox T.write_ (count-1) termCountBox
T.write_ ordered termListBox T.write_ ordered termListBox
T.write_ false showMoreBox T.write_ false showMoreBox
...@@ -704,7 +704,8 @@ badges :: SigmaxT.SGraph -> SigmaxT.NodeIds -> Seq.Seq (Record SigmaxT.Node) ...@@ -704,7 +704,8 @@ badges :: SigmaxT.SGraph -> SigmaxT.NodeIds -> Seq.Seq (Record SigmaxT.Node)
badges graph selectedNodeIds = SigmaxT.graphNodes $ SigmaxT.nodesById graph selectedNodeIds badges graph selectedNodeIds = SigmaxT.graphNodes $ SigmaxT.nodesById graph selectedNodeIds
neighbourBadges :: SigmaxT.SGraph -> SigmaxT.NodeIds -> Seq.Seq (Record SigmaxT.Node) neighbourBadges :: SigmaxT.SGraph -> SigmaxT.NodeIds -> Seq.Seq (Record SigmaxT.Node)
neighbourBadges graph selectedNodeIds = SigmaxT.neighbours graph selectedNodes' where neighbourBadges graph selectedNodeIds = SigmaxT.neighbors graph selectedNodes'
where
selectedNodes' = SigmaxT.graphNodes $ SigmaxT.nodesById graph selectedNodeIds selectedNodes' = SigmaxT.graphNodes $ SigmaxT.nodesById graph selectedNodeIds
--------------------------------------------------------- ---------------------------------------------------------
......
...@@ -14,7 +14,7 @@ import Data.Traversable (class Traversable) ...@@ -14,7 +14,7 @@ import Data.Traversable (class Traversable)
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Effect (Effect) import Effect (Effect)
import Partial.Unsafe (unsafePartial) import Partial.Unsafe (unsafePartial)
import Prelude (class Eq, class Show, map, ($), (&&), (==), (||), (<$>), (<), mod, not, pure) import Prelude (class Eq, class Show, map, ($), (&&), (==), (||), (<$>), (<), mod, not, pure, (<=))
import Record.Unsafe (unsafeGet, unsafeSet) import Record.Unsafe (unsafeGet, unsafeSet)
import Gargantext.Components.Bootstrap.Types (ComponentStatus(..)) import Gargantext.Components.Bootstrap.Types (ComponentStatus(..))
...@@ -171,7 +171,8 @@ graphEdges (Graph {edges}) = edges ...@@ -171,7 +171,8 @@ graphEdges (Graph {edges}) = edges
graphNodes :: SGraph -> Seq.Seq (Record Node) graphNodes :: SGraph -> Seq.Seq (Record Node)
graphNodes (Graph {nodes}) = nodes graphNodes (Graph {nodes}) = nodes
idMap :: forall r t. Traversable t => t { id :: String | r } -> Map.Map String { id :: String | r } idMap :: forall r t. Traversable t
=> t { id :: String | r } -> Map.Map String { id :: String | r }
idMap xs = Map.fromFoldable $ (\x@{ id } -> Tuple id x) <$> xs idMap xs = Map.fromFoldable $ (\x@{ id } -> Tuple id x) <$> xs
edgesGraphMap :: SGraph -> EdgesMap edgesGraphMap :: SGraph -> EdgesMap
...@@ -204,16 +205,16 @@ sub graph (Graph {nodes, edges}) = newGraph ...@@ -204,16 +205,16 @@ sub graph (Graph {nodes, edges}) = newGraph
filteredEdges = edgesFilter edgeFilterFunc graph filteredEdges = edgesFilter edgeFilterFunc graph
newGraph = nodesFilter (\n -> not (Set.member n.id nodeIds)) filteredEdges newGraph = nodesFilter (\n -> not (Set.member n.id nodeIds)) filteredEdges
neighbours :: SGraph -> Seq.Seq (Record Node) -> Seq.Seq (Record Node) neighbors :: SGraph -> Seq.Seq (Record Node) -> Seq.Seq (Record Node)
neighbours g nodes = Seq.fromFoldable $ Set.unions [Set.fromFoldable nodes, sources, targets] neighbors g nodes = Seq.fromFoldable $ Set.unions [if Set.size sources <= 1 then targets else sources]
where where
nodeIds = Set.fromFoldable $ Seq.map _.id nodes nodeIds = Set.fromFoldable $ Seq.map _.id nodes
selectedEdges = neighbouringEdges g nodeIds selectedEdges = neighboringEdges g nodeIds
sources = Set.fromFoldable $ graphNodes $ nodesById g $ Set.fromFoldable $ Seq.map _.source selectedEdges sources = Set.fromFoldable $ graphNodes $ nodesById g $ Set.fromFoldable $ Seq.map _.source selectedEdges
targets = Set.fromFoldable $ graphNodes $ nodesById g $ Set.fromFoldable $ Seq.map _.target selectedEdges targets = Set.fromFoldable $ graphNodes $ nodesById g $ Set.fromFoldable $ Seq.map _.target selectedEdges
neighbouringEdges :: SGraph -> NodeIds -> Seq.Seq (Record Edge) neighboringEdges :: SGraph -> NodeIds -> Seq.Seq (Record Edge)
neighbouringEdges g nodeIds = Seq.filter condition $ graphEdges g neighboringEdges g nodeIds = Seq.filter condition $ graphEdges g
where where
condition {source, target} = (Set.member source nodeIds) || (Set.member target nodeIds) condition {source, target} = (Set.member source nodeIds) || (Set.member target nodeIds)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment