constcollapseIcon=(x, y, r)=>{// 折叠return[['M', x - r, y],['a', r, r,0,1,0, r *2,0],['a', r, r,0,1,0,-r *2,0],['M', x - r +4, y],['L', x - r +2* r -4, y]]}constexpandIcon=(x, y, r)=>{// 拓展return[['M', x - r, y],['a', r, r,0,1,0, r *2,0],['a', r, r,0,1,0,-r *2,0],['M', x - r +4, y],['L', x - r +2* r -4, y],['M', x - r + r, y - r +4],['L', x, y + r -4]]}draw(cfg, group){const{ noSubsetSty, collapsed }= cfg
if(noSubsetSty){// 需要折叠的节点标志,在数据中处理添加标记
group.addShape('circle',{attrs:{x: size,y:0,r:13,fill:'rgba(47, 84, 235, 0.15)',opacity:0,zIndex:-2},name:'collapse-icon-bg'})
group.addShape('marker',{attrs:{x: size,y:0,r:7,symbol: collapsed ? collapseIcon : expandIcon,stroke:'rgba(0,0,0,1)',fill:'rgba(0,0,0,0)',lineWidth:1,cursor:'pointer'},name:'collapse-icon'})}},afterDraw(cfg, group){const icon = group.find(element=> element.get('name')==='collapse-icon')if(icon){const bg = group.find(element=> element.get('name')==='collapse-icon-bg')
icon.on('mouseenter',()=>{
bg.attr('opacity',1)})
icon.on('mouseleave',()=>{
bg.attr('opacity',0)})}},setState(name, value, item){const group = item.getContainer()if(group.get('children')){if(name ==='collapsed'){const marker = item
.get('group').findAll(ele=> ele.get('name')==='collapse-icon')
marker[0]&&
marker[0].attr('symbol', value ? collapseIcon : expandIcon)if(item._cfg.model.depth ===0){
marker[1]&&
marker[1].attr('symbol', value ? collapseIcon : expandIcon)}}}}
this.graph.on('node:click',e=>{// 处理子节点展示问题 + -if(e.target.get('name')==='collapse-icon'){const item = e.item
const nodeId = item.get('id')const children =selectedWorks(nodeId, regroup.nodes, regroup.edges)// 查询相关子节点let newNodes = children.nodes
if(newNodes.length){if(e.item._cfg.model.collapsed){for(let i =0; i < newNodes.length; i++){this.hiddenElements.push(newNodes[i].id)const item =this.graph.findById(newNodes[i].id)this.graph.hideItem(item,true)this.graph.paint()}}else{for(let i =0; i < newNodes.length; i++){this.hiddenElements.splice(this.hiddenElements.indexOf(newNodes[i].id),1)const item =this.graph.findById(newNodes[i].id)this.graph.showItem(item,true)this.graph.paint()}}}this.graph.layout({type:'force',nodeSize:50,preventOverlap:true,animate:false,linkDistance:d=>{return80},nodeStrength:-150,onTick:()=>{this.graph.refreshPositions()},nodeSpacing:d=>{return80}})
e.item._cfg.model.collapsed =!e.item._cfg.model.collapsed
this.graph.setItemState(
e.item,'collapsed',
e.item._cfg.model.collapsed
)this.graph.paint()}})
使用矩阵计算卷积
GEMM算法
矩阵乘法运算(General Matrix Multiplication),形如: C A B , A ∈ R m k , B ∈ R k n , C ∈ R m n C AB, A\in \mathbb{R}^{m\times k},B\in \mathbb{R}^{k\times n},C\in \mathbb{R}^{m\times n} CAB,A∈Rmk,B∈Rk…
面板问题
html部分 <h1>Lorem ipsum dolor sit, amet consectetur adipisicing.</h1><div class"container"><div class"faq"><div class"title-box"><h3 class"title">Lorem, ipsum dolor.<…
读写锁的类型 pthread_rwlock_t
int pthread_rwlock_init(pthread_rwlock_t *restrict rwlock, const pthread_rwlockattr_t *restrict attr);
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
int pthread_rwlo…
c++与数学典型算法的结合
阿姆斯特朗数
// A number is called as Armstrong number if sum of cubes of digits of number is
// equal to the number itself.
// For Example 153 is an Armstrong number because 153 153.
#include <…