Wei Zhao

308 papers A* 22A 42B 34C 9Misc 5Journal 159Unranked 35
YearRankTypeTitle / Venue / Authors
2026 J jnl
IEEE Trans. Serv. Comput.
Fangyi Mou, Zhiqing Tang, Weijia Jia, Wei Zhao
2026 J jnl
Neural Networks
Jingye Tang, Tianqing Zhu, Wanlei Zhou, Wei Zhao
2026 J jnl
Pattern Recognit.
Jian Xu, Chaojie Ji, Yankai Cao, Ye Li, Wei Zhao, Ruxin Wang
2026 J jnl
IEEE Trans. Dependable Secur. Comput.
Chi Liu, Tianqing Zhu, Wanlei Zhou, Wei Zhao
2026 J jnl
Neural Networks
Jingye Tang, Tianqing Zhu, Wanlei Zhou, Wei Zhao
2026 J jnl
IEEE Trans. Mob. Comput.
Xinyu Lu, Zhanbo Feng, Jiong Lou, Chentao Wu, Guangtao Xue, Wei Zhao, Jie Li
2025 J jnl
CoRR
Huiqiang Chen, Tianqing Zhu, Wanlei Zhou, Wei Zhao
2025 J jnl
IEEE Trans. Neural Networks Learn. Syst.
Huiqiang Chen, Tianqing Zhu, Wanlei Zhou, Wei Zhao
2025 J jnl
IEEE Trans. Veh. Technol.
Fangyi Mou, Jiong Lou, Zhiqing Tang, Yuan Wu, Weijia Jia, Yan Zhang, Wei Zhao
2025 J jnl
IEEE Trans. Computers
Shijing Yuan, Beiyu Dong, Jie Li, Song Guo, Hongyang Chen, Chentao Wu, Jie Wu, Wei Zhao
2025 J jnl
CoRR
Honghong Zeng, Jiong Lou, Zhe Wang, Hefeng Zhou, Chentao Wu, Wei Zhao, Jie Li
2025 J jnl
IEEE Trans. Dependable Secur. Comput.
Heng Xu, Tianqing Zhu, Wanlei Zhou, Wei Zhao
2025 J jnl
IEEE Trans. Dependable Secur. Comput.
Honghong Zeng, Jiong Lou, Kailai Li, Chentao Wu, Guangtao Xue, Yuan Luo, Fan Cheng, Wei Zhao, Jie Li
2025 J jnl
CoRR
Chi Liu, Tianqing Zhu, Wanlei Zhou, Wei Zhao
2025 conf
ICC
Wei Zhao, Yunlong Lu, Zhangdui Zhong, Bo Ai, Yueyue Dai, Yan Zhang
2025 A* conf
ICDE
Yuxin Liu, Yuezhang Peng, Hefeng Zhou, Hongze Liu, Xinyu Lu, Jiong Lou, Chentao Wu, Wei Zhao, Jie Li
2025 J jnl
CoRR
Yuxin Liu, Yuezhang Peng, Hefeng Zhou, Hongze Liu, Xinyu Lu, Jiong Lou, Chentao Wu, Wei Zhao, Jie Li
2025 A* conf
IJCAI
Kailai Li, Jiawei Sun, Jiong Lou, Zhanbo Feng, Hefeng Zhou, Chentao Wu, Guangtao Xue, Wei Zhao, Jie Li
2025 J jnl
IEEE Trans. Serv. Comput.
Zhenzheng Li, Jiong Lou, Zhiqing Tang, Jianxiong Guo, Tian Wang, Weijia Jia, Wei Zhao
2025 J jnl
CoRR
Hanshuai Cui, Zhiqing Tang, Zhi Yao, Weijia Jia, Wei Zhao
2025 J jnl
IEEE Trans. Neural Networks Learn. Syst.
Heng Xu, Tianqing Zhu, Lefeng Zhang, Wanlei Zhou, Wei Zhao
2025 J jnl
IEEE Trans. Intell. Transp. Syst.
Xinyu Lu, Jiawei Sun, Jiong Lou, Yusheng Ji, Chentao Wu, Wei Zhao, Guangtao Xue, Yuan Luo, Fan Cheng, Jie Li
2024 J jnl
IEEE Trans. Computers
Honghong Zeng, Jie Li, Jiong Lou, Shijing Yuan, Chentao Wu, Wei Zhao, Sijin Wu, Zhiwen Wang
2024 J jnl
CoRR
Heng Xu, Tianqing Zhu, Wanlei Zhou, Wei Zhao
2024 J jnl
IEEE Trans. Inf. Forensics Secur.
Shuai Zhou, Tianqing Zhu, Dayong Ye, Wanlei Zhou, Wei Zhao
2024 J jnl
IEEE Trans. Mob. Comput.
Zhiqing Tang, Fangyi Mou, Jiong Lou, Weijia Jia, Yuan Wu, Wei Zhao
2024 J jnl
IEEE Trans. Serv. Comput.
Hanshuai Cui, Zhiqing Tang, Jiong Lou, Weijia Jia, Wei Zhao
2024 J jnl
IEEE/ACM Trans. Netw.
Zhiqing Tang, Fangyi Mou, Jiong Lou, Weijia Jia, Yuan Wu, Wei Zhao
2024 J jnl
IEEE Trans. Computers
Zhenzheng Li, Jiong Lou, Jianfei Wu, Jianxiong Guo, Zhiqing Tang, Ping Shen, Weijia Jia, Wei Zhao
2024 J jnl
CoRR
Wenqiang Chen, Jiaxuan Cheng, Leyao Wang, Wei Zhao, Wojciech Matusik
2024 J jnl
Proc. ACM Interact. Mob. Wearable Ubiquitous Technol.
Wenqiang Chen, Jiaxuan Cheng, Leyao Wang, Wei Zhao, Wojciech Matusik
2024 J jnl
IEEE Trans. Mob. Comput.
Jiong Lou, Zhiqing Tang, Weijia Jia, Wei Zhao, Jie Li
2024 J jnl
CoRR
Heng Xu, Tianqing Zhu, Lefeng Zhang, Wanlei Zhou, Wei Zhao
2024 J jnl
Proc. ACM Interact. Mob. Wearable Ubiquitous Technol.
Wenqiang Chen, Shupei Lin, Zhencan Peng, Farshid Salemi Parizi, Seongkook Heo, Shwetak N. Patel, Wojciech Matusik, Wei Zhao, John A. Stankovic
2023 J jnl
IEEE Trans. Neural Networks Learn. Syst.
Yan-Jun Liu, Wei Zhao, Lei Liu, Dapeng Li, Shaocheng Tong, C. L. Philip Chen
2023 conf
ICCPS
Haochen Wang, Zhiwei Shi, Yafei Qiao, Fan Yang, Yuzhe He, Dong Xuan, Wei Zhao
2023 J jnl
IEEE Trans. Mob. Comput.
Jiong Lou, Zhiqing Tang, Songli Zhang, Weijia Jia, Wei Zhao, Jie Li
2023 J jnl
IEEE Trans. Serv. Comput.
Jiong Lou, Hao Luo, Zhiqing Tang, Weijia Jia, Wei Zhao
2023 J jnl
IEEE Trans. Cloud Comput.
Zhiqing Tang, Fuming Zhang, Xiaojie Zhou, Weijia Jia, Wei Zhao
2023 J jnl
IEEE Trans. Knowl. Data Eng.
Xiangyu Hu, Tianqing Zhu, Xuemeng Zhai, Hengming Wang, Wanlei Zhou, Wei Zhao
2023 J jnl
IEEE Trans. Knowl. Data Eng.
Xiangyu Hu, Tianqing Zhu, Xuemeng Zhai, Wanlei Zhou, Wei Zhao
2022 J jnl
Inf. Sci.
Yuzhen Ma, Yan-Jun Liu, Wei Zhao, Jie Lan, Tongyu Xu, Lei Liu
2022 J jnl
Comput. Networks
Songli Zhang, Weijia Jia, Zhiqing Tang, Jiong Lou, Wei Zhao
2022 conf
CNS
Shan Wang, Ming Yang, Bryan Pearson, Tingjian Ge, Xinwen Fu, Wei Zhao
2022 J jnl
IEEE Trans. Cloud Comput.
Jin Wang, Chunming Cao, Jianping Wang, Kejie Lu, Admela Jukan, Wei Zhao
2022 J jnl
IEEE Trans. Dependable Secur. Comput.
Qingyu Yang, Donghe Li, Dou An, Wei Yu, Xinwen Fu, Xinyu Yang, Wei Zhao
2022 J jnl
IEEE Trans Autom. Sci. Eng.
Dou An, Qingyu Yang, Donghe Li, Wei Yu, Wei Zhao, Chao-Bo Yan
2021 J jnl
IEEE Trans. Neural Networks Learn. Syst.
Lei Liu, Wei Zhao, Yan-Jun Liu, Shaocheng Tong, Yueying Wang
2021 J jnl
IEEE Trans. Syst. Man Cybern. Syst.
Yaguang Lin, Xiaoming Wang, Fei Hao, Yichuan Jiang, Yulei Wu, Geyong Min, Daojing He, Sencun Zhu, Wei Zhao
2021 J jnl
IEEE Internet Things J.
Wei Yu, Wei Zhao, Anke Schmeink, Houbing Song, Guido Dartmann
2021 J jnl
IEEE Trans. Knowl. Data Eng.
Pengfei Wan, Xiaoming Wang, Xinyan Wang, Liang Wang, Yaguang Lin, Wei Zhao
2021 J jnl
IEEE CAA J. Autom. Sinica
Wei Zhao, Yanjun Liu, Lei Liu
2021 J jnl
IEEE Internet Things J.
Kaizheng Liu, Ming Yang, Zhen Ling, Huaiyu Yan, Yue Zhang, Xinwen Fu, Wei Zhao
2021 A conf
ICDCS
Shan Wang, Ming Yang, Yue Zhang, Yan Luo, Tingjian Ge, Xinwen Fu, Wei Zhao
2020 conf
EMNLP (Findings)
Pengshuai Li, Xinsong Zhang, Weijia Jia, Wei Zhao
2020 J jnl
CoRR
Pengshuai Li, Xinsong Zhang, Weijia Jia, Wei Zhao
2020 J jnl
IEEE Trans. Veh. Technol.
Jie Lin, Wei Yu, Xinyu Yang, Peng Zhao, Hanlin Zhang, Wei Zhao
2020 J jnl
IEEE J. Sel. Areas Commun.
Yicong Zhang, Jie Li, Shigetomo Kimura, Wei Zhao, Sajal K. Das
2020 J jnl
Complex.
Wei Zhao, Li Tang, Yan-Jun Liu
2020 J jnl
Future Gener. Comput. Syst.
Dou An, Qingyu Yang, Wei Yu, Donghe Li, Wei Zhao
2020 J jnl
CoRR
Kaizheng Liu, Ming Yang, Zhen Ling, Huaiyu Yan, Yue Zhang, Xinwen Fu, Wei Zhao
2020 B conf
COLING
Tianyi Liu, Xiangyu Lin, Weijia Jia, Mingliang Zhou, Wei Zhao
2020 J jnl
CoRR
Tianyi Liu, Xiangyu Lin, Weijia Jia, Mingliang Zhou, Wei Zhao
2020 J jnl
IEEE Trans. Inf. Forensics Secur.
Donghe Li, Qingyu Yang, Wei Yu, Dou An, Yang Zhang, Wei Zhao
2020 J jnl
IEEE Trans. Big Data
Weijia Jia, Hongjian Peng, Na Ruan, Zhiqing Tang, Wei Zhao
2019 J jnl
CoRR
Hou Ian, Biao Chen, Wei Zhao
2019 J jnl
IEEE Internet Things J.
Yang Zhang, Qingyu Yang, Wei Yu, Dou An, Donghe Li, Wei Zhao
2019 J jnl
IEEE Access
Xiaolu Zhang, Demin Li, Wei Wayne Li, Wei Zhao
2019 J jnl
IEEE Trans. Parallel Distributed Syst.
Lin Cui, Fung Po Tso, Song Guo, Weijia Jia, Kaimin Wei, Wei Zhao
2019 J jnl
IEEE Trans. Serv. Comput.
Zhiqing Tang, Xiaojie Zhou, Fuming Zhang, Weijia Jia, Wei Zhao
2019 A conf
ICDCS
Yalong Wu, Yunwei Cui, Wei Yu, Chao Lu, Wei Zhao
2019 A conf
ICDCS
Chunming Cao, Jin Wang, Jianping Wang, Kejie Lu, Jingya Zhou, Admela Jukan, Wei Zhao
2019 J jnl
ACM Trans. Knowl. Discov. Data
Wenmian Yang, Kun Wang, Na Ruan, Wenyuan Gao, Weijia Jia, Wei Zhao, Nan Liu, Yunyong Zhang
2019 J jnl
CoRR
Wenmian Yang, Kun Wang, Na Ruan, Wenyuan Gao, Weijia Jia, Wei Zhao, Nan Liu, Yunyong Zhang
2018 conf
ICC
Joshua Kraunelis, Xinwen Fu, Wei Yu, Wei Zhao
2018 J jnl
IEEE Access
Fan Liang, Wei Yu, Dou An, Qingyu Yang, Xinwen Fu, Wei Zhao
2018 B conf
MASS
Wei Li, Zimu Yuan, Shuhui Yang, Wei Zhao
2018 J jnl
CoRR
Zhen Ling, Kaizheng Liu, Yiling Xu, Chao Gao, Yier Jin, Cliff C. Zou, Xinwen Fu, Wei Zhao
2018 J jnl
Complex.
Xichao Sun, Ming Li, Wei Zhao
2018 J jnl
ACM Trans. Cyber Phys. Syst.
Wei Zhao, Tarek F. Abdelzaher
2018 J jnl
ACM Trans. Cyber Phys. Syst.
Wei Zhao, Tarek F. Abdelzaher
2018 J jnl
IEEE Trans. Syst. Man Cybern. Syst.
Dou An, Qingyu Yang, Wei Yu, Xinyu Yang, Xinwen Fu, Wei Zhao
2018 B conf
MASS
Chao Gao, Zhen Ling, Biao Chen, Xinwen Fu, Wei Zhao
2018 B conf
GLOBECOM
Qinggang Yue, Zupei Li, Chao Gao, Wei Yu, Xinwen Fu, Wei Zhao
2017 conf
WASA
Zhen Ling, Melanie Borgeest, Chuta Sano, Sirong Lin, Mogahid Fadl, Wei Yu, Xinwen Fu, Wei Zhao
2017 J jnl
IEEE Trans. Veh. Technol.
Jie Lin, Wei Yu, Xinyu Yang, Qingyu Yang, Xinwen Fu, Wei Zhao
2017 J jnl
IEEE Internet Things J.
Jie Lin, Wei Yu, Nan Zhang, Xinyu Yang, Hanlin Zhang, Wei Zhao
2017 C conf
IPCCC
Donghe Li, Qingyu Yang, Wei Yu, Dou An, Xinyu Yang, Wei Zhao
2017 B conf
MASS
Qiang Zhai, Fan Yang, Adam C. Champion, Chunyi Peng, Jingchuan Wang, Dong Xuan, Wei Zhao
2017 A conf
ICDCS
Gang Li, Fan Yang, Guoxing Chen, Qiang Zhai, Xinfeng Li, Jin Teng, Junda Zhu, Dong Xuan, Biao Chen, Wei Zhao
2017 J jnl
IEEE Trans. Veh. Technol.
Tianyi Song, Nicholas Capurso, Xiuzhen Cheng, Jiguo Yu, Biao Chen, Wei Zhao
2017 J jnl
IEEE Internet Things J.
Wei Yu, Xinwen Fu, Houbing Song, Anastasios A. Economides, Minho Jo, Wei Zhao
2017 J jnl
Int. J. Robotics Res.
Adriana Schulz, Cynthia R. Sung, Andrew Spielberg, Wei Zhao, Robin Cheng, Eitan Grinspun, Daniela Rus, Wojciech Matusik
2017 J jnl
IEEE Trans. Inf. Forensics Secur.
Qingyu Yang, Dou An, Rui Min, Wei Yu, Xinyu Yang, Wei Zhao
2017 A* conf
INFOCOM
Paul Y. Cao, Gang Li, Adam C. Champion, Dong Xuan, Steve Romig, Wei Zhao
2017 J jnl
IEEE Trans. Parallel Distributed Syst.
Lin Cui, Fung Po Tso, Dimitrios P. Pezaros, Weijia Jia, Wei Zhao
2017 J jnl
Wirel. Commun. Mob. Comput.
Zhen Ling, Melanie Borgeest, Chuta Sano, Jazmyn Fuller, Anthony Cuomo, Sirong Lin, Wei Yu, Xinwen Fu, Wei Zhao
2017 J jnl
IEEE Internet Things J.
Dou An, Qingyu Yang, Wei Yu, Xinyu Yang, Xinwen Fu, Wei Zhao
2017 C conf
IPCCC
Dou An, Qingyu Yang, Wei Yu, Donghe Li, Yang Zhang, Wei Zhao
2017 J jnl
IEEE Trans. Parallel Distributed Syst.
Gang Li, Xinfeng Li, Fan Yang, Jin Teng, Sihao Ding, Yuan F. Zheng, Dong Xuan, Biao Chen, Wei Zhao
2016 C conf
IPCCC
Xinyu Yang, Xialei Zhang, Jie Lin, Wei Yu, Xinwen Fu, Wei Zhao
2016 J jnl
ACM Trans. Cyber Phys. Syst.
Jianjia Wu, Wei Zhao
2016 J jnl
IEEE Trans. Ind. Informatics
Bo Cheng, Lin Cui, Weijia Jia, Wei Zhao, Gerhard P. Hancke
2016 conf
MSN
Qiang Zhai, Fan Yang, Adam C. Champion, Chunyi Peng, Junda Zhu, Dong Xuan, Biao Chen, Yuan F. Zheng, Wei Zhao
2015 A conf
ICDCS
Jie Lin, Wei Yu, Xinyu Yang, Qingyu Yang, Xinwen Fu, Wei Zhao
2015 J jnl
IEEE Trans. Computers
Xinyu Yang, Jie Lin, Wei Yu, Paul-Marie Moulema, Xinwen Fu, Wei Zhao
2015 Misc conf
ICNC
Zimu Yuan, Wei Li, Junda Zhu, Wei Zhao
2015 conf
SoCC
Jingyan Fu, Ligang Hou, Jinhui Wang, Bo Lu, Wei Zhao, Yang Yang
2015 conf
ASICON
Ligang Hou, Jingyan Fu, Jinhui Wang, Na Gong, Wei Zhao, Shuqin Geng
2015 J jnl
CoRR
Zimu Yuan, Wei Li, Zhiwei Xu, Wei Zhao
2015 conf
SCC
Yunwei Zhao, Chi-Hung Chi, Chen Ding, Raymond K. Wong, Wei Zhao, Can Wang
2015 conf
SIGGRAPH Studio
Adriana Schulz, Cynthia R. Sung, Andrew Spielberg, Wei Zhao, Yu Cheng, Ankur M. Mehta, Eitan Grinspun, Daniela Rus, Wojciech Matusik
2015 J jnl
EAI Endorsed Trans. Ubiquitous Environ.
Joshua Kraunelis, Yinjie Chen, Zhen Ling, Xinwen Fu, Wei Zhao
2015 A conf
ICDCS
Lin Cui, Fung Po Tso, Dimitrios P. Pezaros, Weijia Jia, Wei Zhao
2015 J jnl
Enterp. Inf. Syst.
Haitao Zou, Zhiguo Gong, Nan Zhang, Wei Zhao, Jingzhi Guo
2015 A* conf
INFOCOM
Qiang Zhai, Sihao Ding, Xinfeng Li, Fan Yang, Jin Teng, Junda Zhu, Dong Xuan, Yuan F. Zheng, Wei Zhao
2014 A* conf
CCS
Qinggang Yue, Zhen Ling, Xinwen Fu, Benyuan Liu, Kui Ren, Wei Zhao
2014 J jnl
CoRR
Qinggang Yue, Zhen Ling, Benyuan Liu, Xinwen Fu, Wei Zhao
2014 A* conf
PerCom
Wei Zhao
2014 J jnl
IEEE Trans. Parallel Distributed Syst.
Qingyu Yang, Jie Yang, Wei Yu, Dou An, Nan Zhang, Wei Zhao
2013 J jnl
IEEE Trans. Intell. Transp. Syst.
Jin Zhou, C. L. Philip Chen, Long Chen, Wei Zhao
2013 A* conf
INFOCOM
Xinfeng Li, Jin Teng, Qiang Zhai, Junda Zhu, Dong Xuan, Yuan F. Zheng, Wei Zhao
2013 conf
WASA
Yinjie Chen, Zhongli Liu, Xinwen Fu, Wei Zhao
2013 C conf
MobiQuitous
Joshua Kraunelis, Yinjie Chen, Zhen Ling, Xinwen Fu, Wei Zhao
2013 J jnl
Comput. Networks
Zhen Ling, Junzhou Luo, Wei Yu, Xinwen Fu, Weijia Jia, Wei Zhao
2013 A* conf
INFOCOM
Yinjie Chen, Zhongli Liu, Xinwen Fu, Benyuan Liu, Wei Zhao
2012 A conf
ICDCS
Xinyu Yang, Jie Lin, Paul Moulema, Wei Yu, Xinwen Fu, Wei Zhao
2012 J jnl
IEEE Trans. Intell. Transp. Syst.
C. L. Philip Chen, Jin Zhou, Wei Zhao
2012 J jnl
Comput. Networks
Aniket Pingley, Wei Yu, Nan Zhang, Xinwen Fu, Wei Zhao
2012 B conf
GLOBECOM
Zimu Yuan, Wei Li, Adam C. Champion, Wei Zhao
2012 J jnl
Comput. Math. Methods Medicine
Ming Li, Wei Zhao
2012 J jnl
Comput. Math. Methods Medicine
Ming Li, Wei Zhao, Biao Chen
2012 conf
ICCPS
Jie Lin, Wei Yu, Xinyu Yang, Guobin Xu, Wei Zhao
2012 J jnl
IEEE/ACM Trans. Netw.
Ziqiu Yun, Xiaole Bai, Dong Xuan, Weijia Jia, Wei Zhao
2012 conf
ICDCS Workshops
Wei Li, Zimu Yuan, Biao Chen, Wei Zhao
2012 B conf
SMC
C. L. Philip Chen, Jin Zhou, Wei Zhao
2012 J jnl
IEEE Trans. Mob. Comput.
Xinwen Fu, Nan Zhang, Aniket Pingley, Wei Yu, Jie Wang, Wei Zhao
2011 A conf
ICDCS
Dengyuan Wu, Xiuzhen Cheng, Dechang Chen, Wei Cheng, Biao Chen, Wei Zhao
2011 A* conf
INFOCOM
Yinjie Chen, Zhongli Liu, Benyuan Liu, Xinwen Fu, Wei Zhao
2011 J jnl
IEEE Trans. Dependable Secur. Comput.
Wei Yu, Xun Wang, Prasad Calyam, Dong Xuan, Wei Zhao
2011 B conf
GLOBECOM
Qinyu Yang, Jie Yang, Wei Yu, Nan Zhang, Wei Zhao
2011 J jnl
IEEE Trans. Knowl. Data Eng.
Nan Zhang, Wei Zhao
2011 A* conf
INFOCOM
Aniket Pingley, Nan Zhang, Xinwen Fu, Hyeong-Ah Choi, Suresh Subramaniam, Wei Zhao
2010 J jnl
IEEE Trans. Computers
Jianjia Wu, Jyh-Charn Liu, Wei Zhao
2010 J jnl
IEEE Trans. Parallel Distributed Syst.
Ye Zhu, Xinwen Fu, Bryan Graham, Riccardo Bettati, Wei Zhao
2010 A conf
ICDCS
Wei Li, Deng Li, Shuhui Yang, Zhiwei Xu, Wei Zhao
2010 J jnl
IEEE Trans. Computers
Wei Yu, Nan Zhang, Xinwen Fu, Riccardo Bettati, Wei Zhao
2010 A* conf
INFOCOM
Xiaole Bai, Ziqiu Yun, Dong Xuan, Weijia Jia, Wei Zhao
2010 J jnl
IEEE Trans. Parallel Distributed Syst.
Ming Li, Wei Zhao
2010 J jnl
IEEE Trans. Parallel Distributed Syst.
Wei Yu, Nan Zhang, Xinwen Fu, Wei Zhao
2010 J jnl
Telecommun. Syst.
Chengzhi Li, Wei Zhao
2010 J jnl
Telecommun. Syst.
Shengquan Wang, Dong Xuan, Riccardo Bettati, Wei Zhao
2009 J jnl
IEEE Trans. Parallel Distributed Syst.
Wei Yu, Xun Wang, Xinwen Fu, Dong Xuan, Wei Zhao
2009 A conf
ICDCS
Aniket Pingley, Wei Yu, Nan Zhang, Xinwen Fu, Wei Zhao
2009 A conf
ICDCS
Xinwen Fu, Nan Zhang, Aniket Pingley, Wei Yu, Jie Wang, Wei Zhao
2009 J jnl
IEEE Trans. Image Process.
Yang Yang, Vladimir Stankovic, Zixiang Xiong, Wei Zhao
2009 J jnl
IEEE Trans. Commun.
Yang Yang, Samuel Cheng, Zixiang Xiong, Wei Zhao
2008 conf
ICC
Ryan Pries, Wei Yu, Xinwen Fu, Wei Zhao
2008 J jnl
Sci. China Ser. F Inf. Sci.
Hanxing Wang, Guilin Lu, Weijia Jia, Wei Zhao
2008 J jnl
IEEE Trans. Inf. Theory
Yang Yang, Vladimir Stankovic, Zixiang Xiong, Wei Zhao
2008 A conf
DSN
Wei Yu, Nan Zhang, Xinwen Fu, Riccardo Bettati, Wei Zhao
2008 J jnl
IEEE Trans. Knowl. Data Eng.
Nan Zhang, Wei Zhao
2008 C conf
DS-RT
Wei Wayne Li, Gaocai Wang, Wei Zhao
2008 A* conf
INFOCOM
Xun Wang, Wei Yu, Xinwen Fu, Dong Xuan, Wei Zhao
2007 J jnl
Int. J. Secur. Networks
Ye Zhu, Xinwen Fu, Riccardo Bettati, Wei Zhao
2007 conf
S&P
Wei Yu, Xinwen Fu, Steve Graham, Dong Xuan, Wei Zhao
2007 conf
ERSA
Chuan He, Guan Qin, Richard E. Ewing, Wei Zhao
2007 conf
ICIP (3)
Yang Yang, Vladimir Stankovic, Wei Zhao, Zixiang Xiong
2007 J jnl
Microprocess. Microsystems
Chuan He, Guan Qin, Mi Lu, Wei Zhao
2007 J jnl
Computer
Nan Zhang, Wei Zhao
2007 A conf
RTSS
Jianjia Wu, Jyh-Charn Liu, Wei Zhao
2006 J jnl
J. Comb. Optim.
Weijia Jia, Hanxing Wang, Wanqing Tu, Wei Zhao
2006 C conf
ATC
Ming Li, Shengquan Wang, Wei Zhao
2006 conf
ICEBE
Dan Cheng, Zhibin Mai, Jianjia Wu, Guan Qin, Wei Zhao
2006 conf
ASAP
Chuan He, Guan Qin, Mi Lu, Wei Zhao
2006 Misc conf
FCCM
Chuan He, Guan Qin, Mi Lu, Wei Zhao
2006 B conf
ICCCN
Wei Zhao
2006 J jnl
IEEE Trans. Parallel Distributed Syst.
Shengquan Wang, Zhibin Mai, Dong Xuan, Wei Zhao
2006 J jnl
Int. J. Commun. Syst.
Wei Yu, Sriram Chellappan, Dong Xuan, Wei Zhao
2006 conf
ERSA
Chuan He, Guan Qin, Mi Lu, Wei Zhao
2006 A conf
ACSAC
Wei Yu, Xun Wang, Prasad Calyam, Dong Xuan, Wei Zhao
2006 C conf
SSS
Wei Yu, Nan Zhang, Wei Zhao
2005 conf
CIS (2)
Ming Li, Wei Zhao
2005 A* conf
KDD
Nan Zhang, Shengquan Wang, Wei Zhao
2005 J jnl
IEEE Trans. Parallel Distributed Syst.
Rabi N. Mahapatra, Wei Zhao
2005 J jnl
J. Parallel Distributed Comput.
Shengquan Wang, Dong Xuan, Wei Zhao
2005 B conf
GLOBECOM
Ye Zhu, Xinwen Fu, Riccardo Bettati, Wei Zhao
2005 A* conf
VLDB
Nan Zhang, Wei Zhao
2005 B conf
NCA
Wei Zhao
2005 ed.
ICESS
Laurence Tianruo Yang, Xingshe Zhou, Wei Zhao, Zhaohui Wu, Yian Zhu, Man Lin
2005 conf
ERSA
Chuan He, Wei Zhao, Mi Lu
2005 J jnl
Parallel Algorithms Appl.
Weijia Jia, Wanqing Tu, Wei Zhao, Gaochao Xu
2005 ed.
ICCNMC
Xicheng Lu, Wei Zhao
2005 A conf
ICDCS
Xinwen Fu, Ye Zhu, Bryan Graham, Riccardo Bettati, Wei Zhao
2005 B conf
DCC
Yang Yang, Vladimir Stankovic, Zixiang Xiong, Wei Zhao
2005 A conf
IEEE Real-Time and Embedded Technology and Applications Symposium
Jianjia Wu, Jyh-Charn Liu, Wei Zhao
2005 B conf
PAKDD
Nan Zhang, Wei Zhao, Jianer Chen
2005 A conf
IEEE Real-Time and Embedded Technology and Applications Symposium
Shengquan Wang, Sangig Rho, Zhibin Mai, Riccardo Bettati, Wei Zhao
2005 conf
ICCNMC
Hongyun Xu, Xinwen Fu, Ye Zhu, Riccardo Bettati, Jianer Chen, Wei Zhao
2005 Misc conf
FCCM
Chuan He, Wei Zhao, Mi Lu
2005 Misc conf
International Conference on Computational Science (2)
Jan Mandel, Lynn S. Bennethum, Mingshi Chen, Janice L. Coen, Craig C. Douglas, Leopoldo P. Franca, Craig J. Johns, Minjeong Kim, Andrew V. Knyazev, Robert L. Kremens, Vaibhav Kulkarni, Guan Qin, Anthony Vodacek, Jianjia Wu, Wei Zhao, Adam Zornes
2004 conf
PKDD
Nan Zhang, Shengquan Wang, Wei Zhao
2004 Misc conf
International Conference on Computational Science
Jan Mandel, Mingshi Chen, Leopoldo P. Franca, Craig J. Johns, Anatolii A. Puhalskii, Janice L. Coen, Craig C. Douglas, Robert L. Kremens, Anthony Vodacek, Wei Zhao
2004 J jnl
IEEE Trans. Reliab.
Yong Guan, Xinwen Fu, Riccardo Bettati, Wei Zhao
2004 B conf
Data Compression Conference
Yang Yang, Vladimir Stankovic, Zixiang Xiong, Wei Zhao
2004 C conf
DOLAP
Nan Zhang, Wei Zhao, Jianer Chen
2004 conf
PDCS
Jianjia Wu, Dan Cheng, Wei Zhao
2004 J jnl
IEEE Trans. Parallel Distributed Syst.
Weijia Jia, Dong Xuan, Wanqing Tu, Lidong Lin, Wei Zhao
2004 conf
Information Hiding
Xinwen Fu, Bryan Graham, Dong Xuan, Riccardo Bettati, Wei Zhao
2004 A conf
Privacy Enhancing Technologies
Ye Zhu, Xinwen Fu, Bryan Graham, Riccardo Bettati, Wei Zhao
2004 A conf
ICDCS
Yiping Shen, T. C. Lam, Jyh-Charn Liu, Wei Zhao
2004 A* conf
INFOCOM
Yong Xiong, Jyh-Charn Liu, Kang G. Shin, Wei Zhao
2004 A conf
ICDCS
Shengquan Wang, Ripal Nathuji, Riccardo Bettati, Wei Zhao
2004 J jnl
IEEE/ACM Trans. Netw.
Shengquan Wang, Dong Xuan, Riccardo Bettati, Wei Zhao
2004 B conf
MASS
Wei Yu, Thang Nam Le, Dong Xuan, Wei Zhao
2003 B conf
NCA
Shengquan Wang, Dong Xuan, Riccardo Bettati, Wei Zhao
2003 B conf
ICPP
Xinwen Fu, Bryan Graham, Riccardo Bettati, Wei Zhao, Dong Xuan
2003 J jnl
Int. J. Inf. Technol. Decis. Mak.
Ming Li, Chi-Hung Chi, Weijia Jia, Wei Zhao, Wanlei Zhou, Jiannong Cao, Dongyang Long, Qiang Meng
2003 conf
IAW
Wei Yu, Dong Xuan, Sandeep K. Reddy, Riccardo Bettati, Wei Zhao
2003 A conf
ICDCS
Weijia Jia, Hanxing Wang, Maoning Tang, Wei Zhao
2003 C conf
IPCCC
Zhibin Mai, Shengquan Wang, Dong Xuan, Wei Zhao
2003 J jnl
IEEE Trans. Parallel Distributed Syst.
Wei Zhao
2003 J jnl
Real Time Syst.
Joseph Kee-Yin Ng, Shibin Song, Wei Zhao
2003 conf
IAW
Xinwen Fu, Bryan Graham, Riccardo Bettati, Wei Zhao
2003 A conf
ICDCS
Xinwen Fu, Bryan Graham, Riccardo Bettati, Wei Zhao
2003 B conf
GLOBECOM
Shengquan Wang, Dong Xuan, Wei Zhao
2003 J jnl
Real Time Syst.
Byung-Kyu Choi, Dong Xuan, Riccardo Bettati, Wei Zhao, Chengzhi Li
2002 A conf
ICDCS
Yong Guan, Xinwen Fu, Riccardo Bettati, Wei Zhao
2002 J jnl
J. Netw. Syst. Manag.
Weijia Jia, Gaochao Xu, Wei Zhao, Pui-on Au
2002 conf
IEEE Real Time Technology and Applications Symposium
Shengquan Wang, Zhibin Mai, Walt Magnussen, Dong Xuan, Wei Zhao
2002 B conf
LCN
Weijia Jia, Pui-on Au, Gaochao Xu, Wei Zhao
2002 conf
WECWIS
Seong-ryong Kang, Hoh Peter In, Wei Zhao
2001 J jnl
IEEE Trans. Commun.
Xiaohua Jia, Wei Zhao, Jie Li
2001 J jnl
Real Time Syst.
Wei Zhao
2001 A conf
RTSS
Shengquan Wang, Dong Xuan, Riccardo Bettati, Wei Zhao
2001 J jnl
Parallel Distributed Comput. Pract.
Shu Jiang, Nitin H. Vaidya, Wei Zhao
2001 B conf
ICPP
Weijia Jia, Gaochao Xu, Wei Zhao
2001 J jnl
IEEE Trans. Syst. Man Cybern. Part A
Yong Guan, Xinwen Fu, Dong Xuan, P. U. Shenoy, Riccardo Bettati, Wei Zhao
2001 A* conf
INFOCOM
Shengquan Wang, Dong Xuan, Riccardo Bettati, Wei Zhao
2001 conf
IEEE Real Time Technology and Applications Symposium
Shengquan Wang, Dong Xuan, Riccardo Bettati, Wei Zhao
2001 J jnl
J. Interconnect. Networks
Ming Li, Weijia Jia, Wei Zhao
2000 J jnl
IEEE Trans. Parallel Distributed Syst.
Dong Xuan, Weijia Jia, Wei Zhao, Hongwen Zhu
2000 B conf
WISE
Ming Li, Weijia Jia, Wei Zhao
2000 J jnl
IEEE Commun. Mag.
Weijia Jia, Dong Xuan, Wei Zhao
2000 A conf
ICDCS
Byung-Kyu Choi, Dong Xuan, Chengzhi Li, Riccardo Bettati, Wei Zhao
2000 J jnl
Inf. Process. Lett.
Joseph Kee-Yin Ng, Shibin Song, Wei Zhao
2000 B conf
ICPP
Dong Xuan, Chengzhi Li, Riccardo Bettati, Jianer Chen, Wei Zhao
1999 J jnl
J. Commun. Networks
Joseph Kee-Yin Ng, Shibin Song, Chengzhi Li, Wei Zhao
1999 B conf
ICPP
Weijia Jia, Gaochao Xu, Dong Xuan, Wei Zhao
1999 J jnl
IEEE Trans. Parallel Distributed Syst.
Weijia Jia, Wei Zhao, Dong Xuan, Gaochao Xu
1999 J jnl
Eur. Trans. Telecommun.
Weijia Jia, Wei Zhao
1999 J jnl
Eur. Trans. Telecommun.
Weijia Jia, Wei Zhao
1999 B conf
RTCSA
B. Devalla, Riccardo Bettati, Wei Zhao
1999 B conf
ICPP
Chengzhi Li, Riccardo Bettati, Wei Zhao
1999 conf
Workshop on Intrusion Detection and Network Monitoring
Riccardo Bettati, Wei Zhao, D. Teodor
1999 J jnl
IEEE Trans. Computers
Amitava Raha, Sanjay Kamat, Xiaohua Jia, Wei Zhao
1998 B conf
ICPP
Chengzhi Li, Riccardo Bettati, Wei Zhao
1998 B conf
ICPP
Dong Xuan, Weijia Jia, Wei Zhao
1997 A conf
ICDCS
Biao Chen, Anirudha Sahoo, Wei Zhao, Amitava Raha
1997 J jnl
Computer
Biao Chen, Sanjay Kamat, Wei Zhao
1997 A conf
RTSS
Joseph Kee-Yin Ng, Shibin Song, Wei Zhao
1997 A* conf
INFOCOM
Chengzhi Li, Amitava Raha, Wei Zhao
1997 A conf
RTSS
Chengzhi Li, Riccardo Bettati, Wei Zhao
1996 A* conf
INFOCOM
Amitava Raha, Sanjay Kamat, Wei Zhao
1996 J jnl
IEEE Trans. Parallel Distributed Syst.
Sanjay Kamat, Wei Zhao
1996 A conf
ICDCS
Biao Chen, H. Li, Wei Zhao
1996 B conf
LCN
Fang Feng, Cen Li, Amitava Raha, Shiqian Yu, Wei Zhao
1996 J jnl
Real Time Syst.
Nicholas Malcolm, Sanjay Kamat, Wei Zhao
1995 A conf
RTSS
Biao Chen, Sanjay Kamat, Wei Zhao
1995 A conf
ICDCS
Amitava Raha, Sanjay Kamat, Wei Zhao
1995 B conf
LCN
Fang Feng, Sanjay Kamat, Wei Zhao
1995 J jnl
Real Time Syst.
Nicholas Malcolm, Wei Zhao
1995 B conf
ICECCS
Amitava Raha, Nicholas Malcolm, Wei Zhao
1995 B conf
ICNP
Amitava Raha, Sanjay Kamat, Wei Zhao
1994 J jnl
IEEE Trans. Computers
Gopal Agrawal, Biao Chen, Wei Zhao, Sadegh Davari
1994 A* conf
INFOCOM
Sanjay Kamat, Gopal Agrawal, Wei Zhao
1994 B conf
LCN
Amitava Raha, Nicholas Malcolm, Wei Zhao
1994 J jnl
Computer
Nicholas Malcolm, Wei Zhao
1993 B conf
LCN
Nicholas Malcolm, Wei Zhao
1993 A* conf
INFOCOM
Gopal Agrawal, Biao Chen, Wei Zhao
1993 A conf
RTSS
Sanjay Kamat, Nicholas Malcolm, Wei Zhao
1993 conf
RTS
Wei Zhao
1993 A conf
ICDCS
Sanjay Kamat, Wei Zhao
1992 B conf
LCN
Nicholas Malcolm, Wei Zhao
1992 A conf
ICDCS
Gopal Agrawal, Biao Chen, Wei Zhao, Sadegh Davari
1992 J jnl
IEEE Softw.
Swaminathan Natarajan, Wei Zhao
1992 A conf
RTSS
Biao Chen, Gopal Agrawal, Wei Zhao
1992 J jnl
Inf. Softw. Technol.
Edwin K. P. Chong, Wei Zhao
1991 A conf
ICDCS
Cheng-Chew Lim, Lijun Yao, Wei Zhao
1991 J jnl
Computer
Jane W.-S. Liu, Kwei-Jay Lin, Wei-Kuan Shih, Albert Chuang-shi Yu, Jen-Yao Chung, Wei Zhao
1991 J jnl
J. Syst. Softw.
Edwin K. P. Chong, Wei Zhao
1991 A* conf
INFOCOM
Lijun Yao, Wei Zhao
1991 A conf
RTSS
Nicholas Malcolm, Wei Zhao
1990 J jnl
IEEE Trans. Computers
Wei Zhao, John A. Stankovic, Krithi Ramamritham
1990 conf
ICCL
Chris D. Marlin, Wei Zhao, Graeme Doherty, Andrew Bohonis
1990 A* conf
INFOCOM
Nicholas Malcolm, Wei Zhao, Chris J. Barter
1989 J jnl
IEEE Trans. Computers
Krithi Ramamritham, John A. Stankovic, Wei Zhao
1989 J jnl
ACM SIGOPS Oper. Syst. Rev.
Wei Zhao
1989 A conf
RTSS
Wei Zhao, John A. Stankovic
1988 A conf
ICDCS
Wei Zhao, John A. Stankovic, Krithi Ramamritham
1988 J jnl
SIGMOD Rec.
John A. Stankovic, Wei Zhao
1987 A conf
ICDCS
Krithi Ramamritham, John A. Stankovic, Wei Zhao
1987 J jnl
IEEE Trans. Computers
Wei Zhao, Krithi Ramamritham, John A. Stankovic
1987 J jnl
IEEE Trans. Software Eng.
Wei Zhao, Krithi Ramamritham, John A. Stankovic
1987 J jnl
J. Syst. Softw.
Wei Zhao, Krithi Ramamritham
1987 J jnl
IEEE Trans. Software Eng.
Wei Zhao, Krithi Ramamritham
1986 A conf
RTSS
Wei Zhao, Krithi Ramamritham
1985 A conf
RTSS
Wei Zhao, Krithi Ramamritham
redb/extractors/decompiler/apk/smali_cfg.py
← Index redb/extractors/decompiler/apk/smali_cfg.py python
"""Build a basic-block CFG from smali method bodies and compute graph metrics.

Handles both apktool smali (label-based branches like :cond_0) and
androguard fallback smali (offset-based branches like +005h).

Graph metrics match the Binary Ninja CFG pipeline for cross-platform
consistency: cyclomatic complexity (E - N + 2), loop count (back edges),
max BFS depth, max fan-out. Advanced features (topology hash, MD-index,
WL-MinHash, packed adjacency) reuse the generic cfg_features module.
"""

import logging
import re
from collections import deque
from dataclasses import dataclass, field
from typing import Dict, List, Optional, Tuple

from redb.extractors.decompiler.apk.smali_normalization import (
    categorize_opcode,
    CATEGORY_TO_ACFG_INDEX,
)
from redb.extractors.decompiler.bninja.analysis import cfg_features

logger = logging.getLogger(__name__)


# Instruction classification patterns
_IF_RE = re.compile(r"^if-\w+")
_GOTO_RE = re.compile(r"^goto(?:/\d+)?(?:\s|$)")
_RETURN_RE = re.compile(r"^return")
_THROW_RE = re.compile(r"^throw(?:\s|$)")
_SWITCH_RE = re.compile(r"^(?:packed|sparse)-switch\s")

# Label reference in apktool format: :cond_0, :goto_1, etc.
_LABEL_TARGET_RE = re.compile(r":[\w]+")

# Offset reference in androguard format: +005h, -003h
_OFFSET_TARGET_RE = re.compile(r"[+-]\w+h\b")

# Directives and labels
_SKIP_RE = re.compile(r"^\s*(?:\.|#|$)")
_LABEL_DEF_RE = re.compile(r"^\s*:([\w]+)")


@dataclass
class SmaliCFGMetrics:
    """CFG-derived metrics for a smali method."""
    block_count: int = 0
    edge_count: int = 0
    cyclomatic_complexity: int = 1
    loop_count: int = 0
    max_depth: int = 0
    max_fan_out: int = 0
    # Obfuscation scores (parity with code_binja_decompiled_functions_content)
    flattened_score: float = 0.0
    mba_score: float = 0.0
    # Per-block ACFG feature vectors (Gemini-style, same format as BNinja).
    # Each entry: [instr_count, arithmetic, logic, transfer, call,
    #              comparison, memory, successor_count]
    # Empty list if block features were not computed.
    block_features: List[List[int]] = field(default_factory=list)
    # Advanced CFG features (Phase 5 — parity with code_binja_cfg_functions)
    cfg_topology_hash: bytes = field(default_factory=lambda: b'\x00' * 16)
    md_index_topdown: int = 0
    md_index_bottomup: int = 0
    cfg_feature_tlsh: Optional[str] = None
    wl_minhash: List[int] = field(default_factory=lambda: [255] * 128)
    cfg_adjacency: List[int] = field(default_factory=list)


def compute_cfg_metrics(smali_body: str) -> SmaliCFGMetrics:
    """Compute CFG metrics from a smali method body.

    Works with both apktool label-based smali and androguard offset-based
    smali. Falls back to instruction-counting heuristic if CFG construction
    fails.
    """
    if not smali_body or not smali_body.strip():
        return SmaliCFGMetrics()

    lines = smali_body.split("\n")

    # Determine format: apktool (has labels) vs androguard (no labels)
    has_labels = any(_LABEL_DEF_RE.match(line) for line in lines)

    if has_labels:
        return _build_cfg_with_labels(lines)
    else:
        return _build_cfg_from_instructions(lines)


def _parse_instructions(lines: List[str]) -> List[Tuple[int, str]]:
    """Extract instruction lines, skipping directives, labels, blanks, comments.

    Returns list of (original_line_index, stripped_instruction).
    """
    instructions = []
    for i, line in enumerate(lines):
        stripped = line.strip()
        if not stripped or stripped.startswith(".") or stripped.startswith("#"):
            continue
        if stripped.startswith(":"):
            continue
        instructions.append((i, stripped))
    return instructions


def _build_cfg_with_labels(lines: List[str]) -> SmaliCFGMetrics:
    """Build CFG using apktool label-based format.

    Labels (e.g., :cond_0, :goto_1) define branch targets.
    Branch instructions reference labels directly.
    """
    # First pass: collect label positions and instructions
    # We track everything by instruction index (position in instruction list)
    labels: Dict[str, int] = {}  # label_name -> instruction_index
    instructions: List[str] = []
    # Map: line_index -> instruction_index (for label resolution)
    line_to_instr: Dict[int, int] = {}

    instr_idx = 0
    for i, line in enumerate(lines):
        stripped = line.strip()
        if not stripped or stripped.startswith(".") or stripped.startswith("#"):
            continue
        m = _LABEL_DEF_RE.match(stripped)
        if m:
            label_name = ":" + m.group(1)
            labels[label_name] = instr_idx  # next instruction after this label
            continue
        line_to_instr[i] = instr_idx
        instructions.append(stripped)
        instr_idx += 1

    n_instr = len(instructions)
    if n_instr == 0:
        return SmaliCFGMetrics()

    # Identify basic block start points
    block_starts = {0}

    for idx, instr in enumerate(instructions):
        next_idx = idx + 1

        if _IF_RE.match(instr):
            # Conditional branch: fall-through + branch target
            if next_idx < n_instr:
                block_starts.add(next_idx)
            target_label = _extract_label_target(instr)
            if target_label and target_label in labels:
                block_starts.add(labels[target_label])

        elif _GOTO_RE.match(instr):
            # Unconditional jump
            if next_idx < n_instr:
                block_starts.add(next_idx)
            target_label = _extract_label_target(instr)
            if target_label and target_label in labels:
                block_starts.add(labels[target_label])

        elif _RETURN_RE.match(instr) or _THROW_RE.match(instr):
            if next_idx < n_instr:
                block_starts.add(next_idx)

        elif _SWITCH_RE.match(instr):
            if next_idx < n_instr:
                block_starts.add(next_idx)

    # Also add all label targets as block starts
    for label, target_idx in labels.items():
        if target_idx < n_instr:
            block_starts.add(target_idx)

    # Build blocks: sorted list of start indices
    sorted_starts = sorted(block_starts)
    n_blocks = len(sorted_starts)

    # Map instruction index -> block index
    instr_to_block = {}
    for block_idx, start in enumerate(sorted_starts):
        end = sorted_starts[block_idx + 1] if block_idx + 1 < n_blocks else n_instr
        for i in range(start, end):
            instr_to_block[i] = block_idx

    # Collect per-block instruction lists for ACFG feature extraction
    block_instructions: List[List[str]] = []
    for block_idx in range(n_blocks):
        start = sorted_starts[block_idx]
        end = sorted_starts[block_idx + 1] if block_idx + 1 < n_blocks else n_instr
        block_instructions.append(instructions[start:end])

    # Build adjacency lists
    successors: List[List[int]] = [[] for _ in range(n_blocks)]

    for block_idx in range(n_blocks):
        start = sorted_starts[block_idx]
        end = sorted_starts[block_idx + 1] if block_idx + 1 < n_blocks else n_instr
        last_instr_idx = end - 1
        last_instr = instructions[last_instr_idx]

        if _IF_RE.match(last_instr):
            # Fall-through
            if block_idx + 1 < n_blocks:
                _add_edge(successors, block_idx, block_idx + 1)
            # Branch target
            target_label = _extract_label_target(last_instr)
            if target_label and target_label in labels:
                target_block = instr_to_block.get(labels[target_label])
                if target_block is not None:
                    _add_edge(successors, block_idx, target_block)

        elif _GOTO_RE.match(last_instr):
            # Only branch target, no fall-through
            target_label = _extract_label_target(last_instr)
            if target_label and target_label in labels:
                target_block = instr_to_block.get(labels[target_label])
                if target_block is not None:
                    _add_edge(successors, block_idx, target_block)

        elif _RETURN_RE.match(last_instr) or _THROW_RE.match(last_instr):
            # No successors
            pass

        elif _SWITCH_RE.match(last_instr):
            # Fall-through (default case)
            if block_idx + 1 < n_blocks:
                _add_edge(successors, block_idx, block_idx + 1)
            # Switch targets are defined in switch payload (.packed-switch/.sparse-switch)
            # which we can't easily parse from the body alone. The targets are labels
            # referenced in the switch data section. We handle them via label targets.
            _add_switch_targets(
                lines, last_instr, labels, instr_to_block,
                successors, block_idx
            )

        else:
            # Normal instruction at end of block — fall through
            if block_idx + 1 < n_blocks:
                _add_edge(successors, block_idx, block_idx + 1)

    return _compute_metrics_from_cfg(successors, n_blocks, block_instructions)


def _build_cfg_from_instructions(lines: List[str]) -> SmaliCFGMetrics:
    """Build CFG from androguard offset-based format.

    Without labels, we use instruction counting to build a basic CFG.
    Branch targets are hex offsets (e.g., +005h) which we resolve by
    tracking instruction positions.
    """
    instructions = _parse_instructions(lines)
    n_instr = len(instructions)
    if n_instr == 0:
        return SmaliCFGMetrics()

    # Identify basic block starts
    block_starts = {0}

    for idx, (_, instr) in enumerate(instructions):
        next_idx = idx + 1

        if _IF_RE.match(instr):
            if next_idx < n_instr:
                block_starts.add(next_idx)
            # Try to resolve offset target to instruction index
            target = _resolve_offset_target(instr, idx, n_instr)
            if target is not None:
                block_starts.add(target)

        elif _GOTO_RE.match(instr):
            if next_idx < n_instr:
                block_starts.add(next_idx)
            target = _resolve_offset_target(instr, idx, n_instr)
            if target is not None:
                block_starts.add(target)

        elif _RETURN_RE.match(instr) or _THROW_RE.match(instr):
            if next_idx < n_instr:
                block_starts.add(next_idx)

    sorted_starts = sorted(block_starts)
    n_blocks = len(sorted_starts)

    # Map instruction index -> block index
    instr_to_block = {}
    for block_idx, start in enumerate(sorted_starts):
        end = sorted_starts[block_idx + 1] if block_idx + 1 < n_blocks else n_instr
        for i in range(start, end):
            instr_to_block[i] = block_idx

    # Collect per-block instruction lists for ACFG features
    block_instructions: List[List[str]] = []
    for block_idx in range(n_blocks):
        start = sorted_starts[block_idx]
        end = sorted_starts[block_idx + 1] if block_idx + 1 < n_blocks else n_instr
        block_instructions.append(
            [instructions[i][1] for i in range(start, end)]
        )

    # Build adjacency
    successors: List[List[int]] = [[] for _ in range(n_blocks)]

    for block_idx in range(n_blocks):
        start = sorted_starts[block_idx]
        end = sorted_starts[block_idx + 1] if block_idx + 1 < n_blocks else n_instr
        last_idx = end - 1
        _, last_instr = instructions[last_idx]

        if _IF_RE.match(last_instr):
            if block_idx + 1 < n_blocks:
                _add_edge(successors, block_idx, block_idx + 1)
            target = _resolve_offset_target(last_instr, last_idx, n_instr)
            if target is not None:
                target_block = instr_to_block.get(target)
                if target_block is not None:
                    _add_edge(successors, block_idx, target_block)

        elif _GOTO_RE.match(last_instr):
            target = _resolve_offset_target(last_instr, last_idx, n_instr)
            if target is not None:
                target_block = instr_to_block.get(target)
                if target_block is not None:
                    _add_edge(successors, block_idx, target_block)

        elif _RETURN_RE.match(last_instr) or _THROW_RE.match(last_instr):
            pass

        else:
            if block_idx + 1 < n_blocks:
                _add_edge(successors, block_idx, block_idx + 1)

    return _compute_metrics_from_cfg(successors, n_blocks, block_instructions)


def _resolve_offset_target(instr: str, current_idx: int, n_instr: int) -> Optional[int]:
    """Resolve androguard hex offset to an instruction index.

    Androguard offsets (e.g., +005h, -003h) are in 16-bit code units relative
    to the branch instruction. Since most Dalvik instructions are 1-3 code
    units, we approximate: each instruction ≈ 1 code unit for offset
    resolution. This gives an approximate but usable CFG.

    For better accuracy, we treat the offset as an instruction count
    (which is correct for 1-unit instructions and approximate for larger ones).
    """
    m = _OFFSET_TARGET_RE.search(instr)
    if not m:
        return None

    offset_str = m.group(0)
    try:
        # Parse hex offset: +005h -> 5, -003h -> -3
        offset_val = int(offset_str.rstrip("h"), 16)
    except ValueError:
        return None

    target = current_idx + offset_val
    if 0 <= target < n_instr:
        return target
    return None


def _extract_label_target(instr: str) -> Optional[str]:
    """Extract the label target from a branch/goto instruction.

    E.g., 'if-eqz v0, :cond_0' -> ':cond_0'
          'goto :goto_1' -> ':goto_1'
    """
    m = _LABEL_TARGET_RE.search(instr)
    return m.group(0) if m else None


def _add_edge(successors: List[List[int]], src: int, dst: int):
    """Add edge if not duplicate."""
    if dst not in successors[src]:
        successors[src].append(dst)


def _add_switch_targets(
    lines: List[str],
    switch_instr: str,
    labels: Dict[str, int],
    instr_to_block: Dict[int, int],
    successors: List[List[int]],
    block_idx: int,
):
    """Try to resolve switch case targets.

    Switch payloads in apktool smali are defined as:
      .packed-switch 0x0
        :pswitch_0
        :pswitch_1
      .end packed-switch

    We scan the body for label references in switch payload sections.
    """
    # Find the switch payload target label
    target_label = _extract_label_target(switch_instr)
    if not target_label:
        return

    # Scan for packed-switch/sparse-switch payload sections
    in_switch = False
    for line in lines:
        stripped = line.strip()
        if stripped.startswith(".packed-switch") or stripped.startswith(".sparse-switch"):
            in_switch = True
            continue
        if stripped.startswith(".end packed-switch") or stripped.startswith(".end sparse-switch"):
            in_switch = False
            continue
        if in_switch:
            # Lines in switch payload are label references
            m = _LABEL_TARGET_RE.search(stripped)
            if m:
                case_label = m.group(0)
                if case_label in labels:
                    target_block = instr_to_block.get(labels[case_label])
                    if target_block is not None:
                        _add_edge(successors, block_idx, target_block)


def _build_block_features(
    block_instructions: List[List[str]],
    successors: List[List[int]],
    n: int,
) -> List[List[int]]:
    """Build Gemini-style ACFG feature vectors per block from smali instructions.

    Same 8-element format as Binary Ninja's build_block_features:
    [instr_count, arithmetic, logic, transfer, call, comparison, memory, successor_count]

    Uses semantic opcode categorization (analogous to LLIL operation categories)
    to map each Dalvik instruction to one of 7 category bins.
    """
    features = []
    for i in range(n):
        cats = [0, 0, 0, 0, 0, 0, 0]  # 7 categories
        instrs = block_instructions[i] if i < len(block_instructions) else []
        for instr in instrs:
            opcode = instr.split(None, 1)[0] if instr else ""
            category = categorize_opcode(opcode)
            acfg_idx = CATEGORY_TO_ACFG_INDEX.get(category, 6)
            cats[acfg_idx] += 1

        features.append([
            min(len(instrs), 65535),
            min(cats[0], 65535),  # arithmetic
            min(cats[1], 65535),  # logic
            min(cats[2], 65535),  # transfer
            min(cats[3], 65535),  # call
            min(cats[4], 65535),  # comparison
            min(cats[5], 65535),  # memory
            min(len(successors[i]), 65535),
        ])
    return features


def _compute_metrics_from_cfg(
    successors: List[List[int]],
    n: int,
    block_instructions: Optional[List[List[str]]] = None,
) -> SmaliCFGMetrics:
    """Compute all graph metrics from the adjacency list."""
    if n == 0:
        return SmaliCFGMetrics()

    edge_count = sum(len(s) for s in successors)

    # Cyclomatic complexity: E - N + 2
    cc = edge_count - n + 2
    if cc < 1:
        cc = 1

    # Loop count: back edges via iterative DFS
    loop_count = _count_back_edges(successors, n)

    # Max BFS depth from entry
    max_depth = _bfs_max_depth(successors, n)

    # Max fan-out
    max_fan_out = max(len(s) for s in successors) if successors else 0

    # Per-block ACFG features
    bb_features = []
    if block_instructions is not None:
        bb_features = _build_block_features(block_instructions, successors, n)

    # Obfuscation scores
    flattened = _compute_flattened_score(successors, n)
    mba = (
        _compute_mba_score(block_instructions, n)
        if block_instructions is not None
        else 0.0
    )

    # Advanced CFG features — reuse generic cfg_features module
    # Build predecessors from successors
    predecessors = [[] for _ in range(n)]
    for src, targets in enumerate(successors):
        for tgt in targets:
            predecessors[tgt].append(src)

    try:
        bfs = cfg_features.bfs_order(successors, n)
        topology_hash = cfg_features.compute_topology_hash(successors, bfs, n)
        md_topdown = cfg_features.compute_md_index_topdown(
            successors, predecessors, bfs
        )
        md_bottomup = cfg_features.compute_md_index_bottomup(
            successors, predecessors, n
        )
        cfg_tlsh = (
            cfg_features.compute_cfg_feature_tlsh(bb_features, bfs)
            if bb_features
            else None
        )
        wl_minhash = (
            cfg_features.compute_wl_minhash(
                successors, predecessors, bb_features, n
            )
            if bb_features
            else [255] * 128
        )
        adjacency = cfg_features.pack_adjacency(successors)
    except Exception as e:
        logger.debug("Advanced CFG features failed: %s", e)
        topology_hash = b'\x00' * 16
        md_topdown = 0
        md_bottomup = 0
        cfg_tlsh = None
        wl_minhash = [255] * 128
        adjacency = []

    return SmaliCFGMetrics(
        block_count=n,
        edge_count=edge_count,
        cyclomatic_complexity=cc,
        loop_count=loop_count,
        max_depth=max_depth,
        max_fan_out=max_fan_out,
        flattened_score=flattened,
        mba_score=mba,
        block_features=bb_features,
        cfg_topology_hash=topology_hash,
        md_index_topdown=md_topdown,
        md_index_bottomup=md_bottomup,
        cfg_feature_tlsh=cfg_tlsh,
        wl_minhash=wl_minhash,
        cfg_adjacency=adjacency,
    )


def _compute_dominators(successors: List[List[int]], n: int) -> List[int]:
    """Compute immediate dominators using iterative dataflow algorithm.

    Returns idom[i] = immediate dominator of block i.  idom[0] = -1 (entry).
    """
    if n == 0:
        return []

    # Build predecessors
    preds: List[List[int]] = [[] for _ in range(n)]
    for src, targets in enumerate(successors):
        for tgt in targets:
            preds[tgt].append(src)

    # Initialize: dom[0] = {0}, dom[i] = all blocks
    all_blocks = set(range(n))
    dom = [all_blocks.copy() for _ in range(n)]
    dom[0] = {0}

    changed = True
    while changed:
        changed = False
        for i in range(1, n):
            if not preds[i]:
                new_dom = {i}
            else:
                new_dom = all_blocks.copy()
                for p in preds[i]:
                    new_dom &= dom[p]
                new_dom.add(i)
            if new_dom != dom[i]:
                dom[i] = new_dom
                changed = True

    # Extract immediate dominators from dominator sets
    idom = [-1] * n
    for i in range(1, n):
        # idom[i] = the dominator of i (other than i itself) that is
        # dominated by all other dominators of i
        doms_of_i = dom[i] - {i}
        if not doms_of_i:
            continue
        for candidate in doms_of_i:
            # candidate is idom if it is dominated by all other dominators
            if all(candidate in dom[other] for other in doms_of_i):
                # candidate dominates no other dominator besides itself
                # (i.e., it's the closest dominator)
                if all(
                    other == candidate or candidate not in dom[other]
                    for other in doms_of_i
                ):
                    pass  # not the closest
                else:
                    continue
            else:
                continue
        # Simpler approach: idom is the element in doms_of_i with the
        # largest dominator set (closest to i in the dominator tree)
        idom[i] = max(doms_of_i, key=lambda d: len(dom[d]))

    return idom


def _compute_flattened_score(
    successors: List[List[int]], n: int
) -> float:
    """Detect control flow flattening — same heuristic as Binary Ninja's
    ObfuscationScores.flattened_score (Tim Blazytko).

    Walks over all basic blocks, finds those with back edges (loop headers),
    and computes the ratio of blocks dominated by them to total blocks.
    """
    if n <= 1:
        return 0.0

    idom = _compute_dominators(successors, n)

    # Build dominator tree children from idom
    dom_children: List[List[int]] = [[] for _ in range(n)]
    for i in range(1, n):
        if idom[i] >= 0:
            dom_children[idom[i]].append(i)

    max_ratio = 0.0

    for block in range(n):
        # Get all blocks dominated by this block (reachable in dominator tree)
        dominated = set()
        worklist = [block]
        while worklist:
            b = worklist.pop()
            dominated.add(b)
            worklist.extend(dom_children[b])

        # Check for a back edge: any predecessor of block is in dominated set
        has_back_edge = False
        for src, targets in enumerate(successors):
            if block in targets and src in dominated:
                has_back_edge = True
                break

        if not has_back_edge:
            continue

        ratio = len(dominated) / n
        if ratio > max_ratio:
            max_ratio = ratio

    return max_ratio


def _compute_mba_score(block_instructions: List[List[str]], n: int) -> float:
    """Compute mixed boolean-arithmetic score for a smali method.

    Same concept as Binary Ninja's ObfuscationScores.MBA_score: ratio of
    instructions that mix arithmetic and logic operations.

    At the smali level, we check each instruction's opcode:
    - Arithmetic: add, sub, mul, div, rem, neg
    - Logic: and, or, xor, shl, shr, ushr, not

    Since Dalvik instructions are single operations (unlike x86 complex
    instructions or HLIL expression trees), we check per-instruction whether
    the method mixes both categories. The score is the fraction of
    instructions belonging to the minority category when both are present.
    """
    ARITHMETIC_OPS = {"add", "sub", "mul", "div", "rem", "neg"}
    LOGIC_OPS = {"and", "or", "xor", "shl", "shr", "ushr", "not"}

    arithmetic_count = 0
    logic_count = 0
    total_instructions = 0

    for block in block_instructions[:n]:
        for instr in block:
            opcode = instr.split(None, 1)[0] if instr else ""
            # Strip type suffix: add-int/2addr -> add
            base = opcode.split("-")[0] if "-" in opcode else opcode
            total_instructions += 1
            if base in ARITHMETIC_OPS:
                arithmetic_count += 1
            elif base in LOGIC_OPS:
                logic_count += 1

    if total_instructions == 0:
        return 0.0

    # MBA is present when both arithmetic and logic operations co-exist.
    # Score = min(arith, logic) / total — measures how much mixing occurs.
    if arithmetic_count == 0 or logic_count == 0:
        return 0.0

    return min(arithmetic_count, logic_count) / total_instructions


def _count_back_edges(successors: List[List[int]], n: int) -> int:
    """Count natural loops via iterative DFS back-edge detection.

    Same algorithm as bninja/analysis/cfg_features.py:count_back_edges.
    """
    if n == 0:
        return 0

    WHITE, GRAY, BLACK = 0, 1, 2
    color = [WHITE] * n
    back_edges = 0

    stack = [(0, iter(successors[0]))]
    color[0] = GRAY

    while stack:
        u, children = stack[-1]
        try:
            v = next(children)
            if color[v] == GRAY:
                back_edges += 1
            elif color[v] == WHITE:
                color[v] = GRAY
                stack.append((v, iter(successors[v])))
        except StopIteration:
            color[u] = BLACK
            stack.pop()

    return back_edges


def _bfs_max_depth(successors: List[List[int]], n: int) -> int:
    """Maximum BFS depth from entry block.

    Same algorithm as bninja/analysis/cfg_features.py:bfs_max_depth.
    """
    if n == 0:
        return 0

    depth = {0: 0}
    max_d = 0
    queue = deque([0])

    while queue:
        node = queue.popleft()
        for s in successors[node]:
            if s not in depth:
                depth[s] = depth[node] + 1
                if depth[s] > max_d:
                    max_d = depth[s]
                queue.append(s)

    return max_d